[英]php curl on live server issue
請幫我。 我正在嘗試制作 instagram 下載器。 我運行此代碼並從帖子中收集照片/視頻 url。
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.instagram.com/tv/CL9blYrF3gt/?__a=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $server_output;
?>
它在本地主機上工作正常。 但不能在實時服務器上工作。 在本地主機中,它返回 http 狀態代碼 200,但在實時服務器中,它返回 http 狀態代碼 302。
一切都是一樣的。 但為什么它不工作? 我該如何解決?
我也通過 python 請求嘗試它。 還是行不通。 它僅適用於 xampp localhost。
You should add the CURLOPT_FOLLOWLOCATION
option to allow cURL to request the new URL, defined in the HTTP header of the response.
A 302 HTTP 代碼為302 Found
“表示請求的資源已經暫時移動到了Location頭給出的URL” 。
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.