2015-02-07 41 views
0

解决。通过php隐藏ios安装应用程序的下载链接

我有一个安装在safari中工作的ios应用程序的链接。

<a href="itms-services://?action=download-manifest&url=https://acqshop.com/manifest/category/Farsi/ashpazi.plist"></a> 

现在我想隐藏用户的链接,但我不知道如何做到这一点。 我的onclick用于链接:

<a href="javascript:void(0);" onclick="javascript:install();" target="Farsi/ashpazi.plist"></a> 

function install() { 
if (!isMobile()) { 
    alert('you can download from ios devices'); 
    return; 
} 
var post_link = $(this).attr("target"); 
url = 'install.php?name='+post_link; 
window.location.href = url; 
} 

和install.php了:

<?php 
$name = $_GET['name'];  
$path = 'itms-services://?action=download-manifest&url=https://acqshop.com/manifest/category/'.$name; 
$mm_type="application/octet-stream"; 
header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Cache-Control: public"); 
header("Content-Description: File Transfer"); 
header("Content-Type: " . $mm_type); 
header("Content-Length: " .(string)(filesize($path))); 
header('Content-Disposition: attachment; filename="'.basename($path).'"'); 
header("Content-Transfer-Encoding: binary\n"); 
readfile($path); // outputs the content of the file 
exit(); 
?> 

,但它不能正常工作。我的错误是什么?
你可以看到一个例子的onclick功能,在这个网站上下载iOS应用:
ipa.othman.tv/ipa/vi2.php
但我不能understant什么是在installvi2.php功能
(请参阅页面源)
谢谢。

感谢@Shynggys 我改变install.php了到:

<?php 
$name = $_GET['name'];  
$path = 'itms-services://?action=download-manifest&url=https://acqshop.com/manifest/category/'.$name; 
$mm_type="application/octet-stream"; 
header("Pragma: public"); 
header("Expires: 0"); 
header('Location:' .$path); 
?> 
+0

,你可以看到的onclick功能相关的例子来下载iOS应用在这个网站:http://ipa.othman.tv/ipa/vi2.php,但我不能了解什么是功能离子在installvi2.php – fraweb 2015-02-07 18:45:05

回答

0

尝试使用绝对URL,而不是相对的,从功能返回“假”,“安装”,它应该是这个样子:

function install() { 
if (!isMobile()) { 
    alert('you can download from ios devices'); 
    return; 
} 
var post_link = $(this).attr("target"); 
url = 'http://MyWebSite.kz/install.php?name='+post_link; 
window.location.href = url; 
return false; 
} 

希望它可以帮助

+0

thanks.but注意改变了,我的问题是函数在install.php, – fraweb 2015-02-07 20:24:04

+0

有没有什么办法可以解决这个问题? – fraweb 2015-02-08 17:18:17

+0

尝试只是将用户从install.php重定向到您的链接 – 2015-02-08 19:14:01