php获取应用宝app下载连接

慕乐池
2023-12-01

app在应用宝上的下载速度很快,如果能点击直接下载,无需跳转到应用宝,岂不快哉。

源代码如下:

<?php
/**
 * @Author: Ding Jianlong
 * @Date:   2018-10-12 13:57:11
 * @Last Modified by:   Ding Jianlong
 * @Last Modified time: 2018-10-12 14:59:37
 */

//以网易邮箱为例
$appname = 'com.netease.mobimail';
//手机访问app.qq.com搜索,看地址栏
$appid = '1101773241';

//1、正则匹配网页下载地址,https
$str = file_get_contents('http://android.myapp.com/myapp/detail.htm?apkName='.$appname);

$regex = '/class="det-down-btn" .+ appname/';
preg_match($regex, $str,$arr);
//var_dump($arr);

$regex2 = '/data-apkUrl="(.+)"/';
preg_match($regex2, $arr[0],$arr2);

if($arr2[1]){
	$path =  $arr2[1];
}else{
	//2、调用官方接口,http
	$url = 'http://mapp.qzone.qq.com/cgi-bin/mapp/mapp_info?type=appinfo&appid='.$appid.'&packageName=&platform=touch&network_type=undefined&resolution=360x640';

	$data = file_get_contents($url);
	//var_dump(json_decode($data,true));
	$path = json_decode($data,true)['app'][0]['url'];
}

//echo $path;die;
header('location:'.$path);

 

 类似资料: