繁体   English   中英

php curl 关于实时服务器问题

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM