最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

php识别访问手机操作系统,并直接下载相应的安装包

业界 admin 0浏览 0评论
<?php
header("Content-Type:text/html; charset=utf-8");
if(get_device_type()=='ios'){
	$ff='huanbaoba.ipa';
	header('application/iphone');
	header('Content-Disposition:attachment;filename="huanbaoba.ipa"');
}else{
	$ff='huanbaoba.apk';
	header('application/vnd.android.package-archive');
	header('Content-Disposition:attachment;filename="huanbaoba.apk"');
	
}
readfile($ff); 
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未测试

<?php
header("Content-Type:text/html; charset=utf-8");
if(get_device_type()=='ios'){
	$ff='huanbaoba.ipa';
	header('application/iphone');
	header('Content-Disposition:attachment;filename="huanbaoba.ipa"');
}else{
	$ff='huanbaoba.apk';
	header('application/vnd.android.package-archive');
	header('Content-Disposition:attachment;filename="huanbaoba.apk"');
	
}
readfile($ff); 
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未测试

发布评论

评论列表 (0)

  1. 暂无评论