简体   繁体   English

301永久性移动PHP Laravel

[英]301 Moved Permanently PHP Laravel

Hi I'm trying to get data from anther site so I used 嗨,我正在尝试从其他网站上获取数据,所以我使用了

    $url = 'MY_URL' . $route . '/' . $id;
    $ch = curl_init($url);

    curl_setopt($ch, CURLOPT_HTTPHEADER, array('url: ACCESS_URL', 'token: TOKEN'));
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, $type);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;

so I get 301 Moved Permanently output I works fine on local machine put after uploading I got that error ,any suggestions 所以我得到301 Moved Permanently输出,上传后在本地计算机上工作正常,我得到了这个错误,任何建议

我的问题是缺少组件curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

您需要专门告诉cURL遵循重定向:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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