2015-02-07 72 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

相關問題