2016-10-22 78 views
2
獲取數據

我正在使用第三方API在公共URL上向我們提供數據。我希望這些數據在我的網站上,而用戶不知道數據從何處獲取的確切位置。隱藏網站的URL我從

實施例: 數據從該URL中獲取:https://example.com/1477116779.16443511_0.mp3 數據將被顯示在此:www.zigsaw.in/telephonicinterviews/1477116779.16443511_0.mp3

我試圖使用的IFrame

<iframe src="https://example.com/1477116779.16443511_0.mp3" width="100%" height="100%" frameborder="0" scrolling="no" /> 

,但它允許「在新標籤頁中打開鏈接」,從而顯示原始頁面源

背景:我們是一家招聘啓動公司,不想讓外面的人知道我們的小jugaad 。最終,他們會知道,但我更喜歡3-4個月的頭馬。

P.S. :下載數據&上傳到我的服務器上也是一個解決方案,但我不想不必要的負擔我的託管。由於這些是音頻文件,因此佔用大量空間。

回答

2

沒有爲這個問題沒有HTML的解決方案 - 您可以將URL改寫爲您的服務器,但你需要一個腳本,該腳本獲取原始URL並顯示數據 - 這樣的事情:

<?php 
header('Content-disposition: attachment; filename=filename.mp3'); 
header('Content-type: application/octet-stream'); // adjust this to your real fileType 
header('Content-type: audio/mpeg'); // use this for mp3 
echo file_get_content('http://your-url.com/123'); 
?> 

然後鏈接到這個腳本 - 瞧 - 用戶只能看到你的網址,而不是原來的網址。腳本正在傳遞數據。

+0

效果很好。謝謝:) 任何想法如何播放音頻&不強制用戶下載它? –

+0

請參閱我的編輯內容 - 使用其他內容類型「audio/mpeg」。 – cklm

+0

它還在下載 –

1

您可以禁用右鍵點擊元素,雖然這不會阻止某人看到inspect element選項卡中的網址,甚至不能在原始html/page source頁面中查看它。

因此,要禁用右鍵單擊iframe元素,請使用此選項。 (1鍵是正常點擊,2是右鍵。)

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script> 
    $("iframe").click(function(event) { 
     if(event.button==2) { 
      return false;  
     } 
    }); 
</script> 
1

如果您使用的Nginx作爲你可以在代理服務器級別的請求您的Web服務器。創建一個充當API代理的子域。

配置簡單:

http { 
    sendfile  on; 

    keepalive_timeout 2000; 

    server { 
     listen  80; 
     server_name data.example.com; 

     location/{ 
      proxy_pass https://www.zigsaw.in; 
      proxy_pass_request_body on; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     } 
    } 
} 

閱讀Nginx的文檔,瞭解有關ngx_http_proxy_module進一步的細節。