简体   繁体   English

php curl 关于实时服务器问题

[英]php curl on live server issue

please help me.请帮我。 I'm trying to making instagram downloader.我正在尝试制作 instagram 下载器。 I run this code and collect photo/video url from post.我运行此代码并从帖子中收集照片/视频 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;
?>

it work fine on localhost.它在本地主机上工作正常。 but cannot work on live server.但不能在实时服务器上工作。 in localhost it's return http status code 200 but in live server it's return http status code 302.在本地主机中,它返回 http 状态代码 200,但在实时服务器中,它返回 http 状态代码 302。

everything is same.一切都是一样的。 but why it's not working?但为什么它不工作? how can i solve it?我该如何解决?

i also try it by python requests.我也通过 python 请求尝试它。 still not working.还是行不通。 it is work only on xampp localhost.它仅适用于 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. 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 Code is 302 Found that "indicates that the resource requested has been temporarily moved to the URL given by the Location header" . 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