从itms-services协议中获取ipa的下载地址

适用场景 app未上线

case 'download':
        $type = $_REQUEST['type'] ?: get_device_type();
        if ($type === 'ios') {
            header("Location: http://{$_SERVER['HTTP_HOST']}/wap/download.php");
//            header("Location: itms-services:///?action=download-manifest&url=........");
        } else {
            $fileName = '0.2.2.1.apk';
            $path = DT_ROOT . '/download/android/' . $fileName;
            //  文件类型,作为头部发送给浏览器
            $type = filetype($path);
            // 获取时间和日期
            $today = date("F j, Y, g:i a");
            $time = time();
            // 发送文件头部
            header("Content-type: $type");
            header("Content-Disposition: attachment;filename={$fileName}");
            header("Content-Transfer-Encoding: binary");
            header('Pragma: no-cache');
            header('Expires: 0');
            // 发送文件内容
            set_time_limit(0);
            readfile($path);
        }
        break;

从itms-services协议中获取ipa的下载地址_第1张图片

function get_device_type()
{
//全部变成小写字母
    $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $type = 'other';
//分别进行判断
    if (strpos($agent, 'iphone') || strpos($agent, 'ipad')) {
        $type = 'ios';
    }
    if (strpos($agent, 'android')) {
        $type = 'android';
    }
    return $type;
}

ios跳转可用itms-services协议的链接:itms-services协议的链接
或者用 跳转页面实现方式
$key = ‘itms-services:///?action=download-manifest&url=…itms-servicesb-1599526479.plist’;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
    <title>应用名字</title>
</head>
<body>
<h1 style="font-size:80pt">如果点击无法下载安装,请复制超链接到浏览器中打开</h1>
<h1 style="font-size:100pt">
    <a href="{$key}" title="iPhone">点击下载</a>
</h1>
</body>
</html>

你可能感兴趣的:(itms-services,app下载方式,php,http)