简体   繁体   中英

php curl on live server issue

please help me. I'm trying to making instagram downloader. I run this code and collect photo/video url from post.

<?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.

everything is same. but why it's not working? how can i solve it?

i also try it by python requests. still not working. it is work only on 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 Code is 302 Found that "indicates that the resource requested has been temporarily moved to the URL given by the Location header" .

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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