当前位置:Gxlcms > PHP教程 > itms-services协议:跳转网页部署及PHP动态生成iOS渠道包IPA一键安装之plist

itms-services协议:跳转网页部署及PHP动态生成iOS渠道包IPA一键安装之plist

时间:2021-07-01 10:21:17 帮助过:21人阅读

相信很多人尝试过使用揣果测试库(http://ipa.chuaiguo.com/)的无线安装测试IPA安装包功能。有心人一定注意到其itms-services协议的一键安装地址的url=部分并不是我们常见的plist文件路径,而是一个install.php通过增加参数的形式自动生成输出了plist。之前因为笔者的项目中渠道包不多,所以懒得去写这样一个文件帮助部署,可是最近,笔者的项目的渠道包不断增多了,显然部署多个plist文件管理上似乎越来越麻烦了,于是笔者开始仿照揣果实现了并结合自己项目的需求,实现了PHP动态生成 iOS渠道包IPA一键安装之plist。这里跟大家分享一下,希望对您有所帮助。

 iOS 一键安装下载中...
 startElement('dict'); foreach($dict as $k => &$v)  { $x->writeElement('key', $k); xmlWriteValue($x, $v); } $x->endElement();}  //向xml节点中写入数组(array)function xmlWriteArray(XMLWriter $x, &$arr) { $x->startElement('array'); foreach($arr as &$v) xmlWriteValue($x, $v); $x->endElement();}//根据类型向xml节点中写入值function xmlWriteValue(XMLWriter $x, &$v) { if (is_int($v) || is_long($v)) $x->writeElement('integer', $v); elseif (is_float($v) || is_real($v) || is_double($v)) $x->writeElement('real', $v); elseif (is_string($v)) $x->writeElement('string', $v); elseif (is_bool($v)) $x->writeElement($v?'true':'false'); elseif (isDict($v)) xmlWriteDict($x, $v); elseif (is_array($v)) xmlWriteArray($x, $v); else  { trigger_error("Unsupported data type in plist ($v)", E_USER_WARNING); $x->writeElement('string', $v); }}//创建plistfunction createplist(){ $ssl_server = 'https://www.lessney.com/'; $target_name = 'Sample'; $bundle_identifier = 'com.lessney.' . $target_name; $subtitle = 'Zero Status Inc.'; $title = '示例程序'; $versionname = $_GET['v']; if (!$versionname)  { $versionname = '1.0.0'; } $versioncode = str_replace('.', '', $versionname); $channelid = $_GET['cid']; if (!$channelid)  { $channelid = '0'; } header('Content-Type: application/xml'); $plist = new XmlWriter(); $plist->openMemory(); $plist->setIndent(TRUE); $plist->startDocument('1.0', 'UTF-8'); $plist->writeDTD('plist', '-//Apple//DTD PLIST 1.0//EN', 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'); $plist->startElement('plist'); $plist->writeAttribute('version', '1.0'); $pkg = array(); $pkg['kind'] = 'software-package'; $pkg['url'] = $ssl_server . $target_name .'_v' . $versioncode . '_' .$channelid . '.ipa'; $displayimage = array(); $displayimage['kind'] = 'display-image'; $displayimage['needs-shine'] = TRUE; $displayimage['url'] = $ssl_server . 'Icon.png'; $fullsizeimage = array(); $fullsizeimage['kind'] = 'full-size-image'; $fullsizeimage['needs-shine'] = TRUE; $fullsizeimage['url'] = $ssl_server . 'iTunesArtwork.png'; $assets = array(); $assets[] = $pkg; $assets[] = $displayimage; $assets[] = $fullsizeimage; $metadata = array(); $metadata['bundle-identifier'] = $bundle_identifier; $metadata['bundle-version'] = $versionname; $metadata['kind'] = 'software'; $metadata['subtitle'] = $subtitle; $metadata['title'] = $title; $items0 = array(); $items0['assets'] = $assets; $items0['metadata'] = $metadata; $items = array(); $items[] = $items0; $root = array(); $root['items'] = $items; xmlWriteValue($plist, $root); $plist->endElement(); $plist->endDocument(); return $plist->outputMemory();}//
输出plistecho createplist();?>

人气教程排行