cURL 重定向导致错误
我目前正在尝试使用 method=GET 来卷曲表单。我在网址末尾有包含数据的完整链接。如果我将链接直接放入地址栏中,它就可以工作。当我卷曲链接时,它给我一个“未找到对象!”错误并将地址栏 URL 更改为 http://localhost/ocs?name=mike。
我相信我有与此问题类似的问题,但我不确定此问题的解决方案是什么: Curl 重定向问题
我目前拥有的代码:
$ch = curl_init();
$url = "http://www.example.com/ocs?name=mike";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$data = curl_exec ($ch);
curl_close ($ch);
echo $data;
非常感谢您的帮助
I am currently trying to curl a form with method=GET. I have the complete link with the data on the end of the url. If I place the link directly into the address bar it works. When I curl the link it gives me an "Object not found!" error and changes the address bar URL to http://localhost/ocs?name=mike.
I believe I have a similar problem to this question but I am unsure what the solution to this question was:
Curl Redirect Problem
Code I currently have:
$ch = curl_init();
$url = "http://www.example.com/ocs?name=mike";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$data = curl_exec ($ch);
curl_close ($ch);
echo $data;
Thank you very much for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试设置卷曲选项“CURL_FOLLOWOCATION”和“CURL_MAXREDIRS”。这些将允许您的 CURL 请求遵循目标 URL 的重定向。
You may try setting the curl options "CURL_FOLLOWOCATION" and "CURL_MAXREDIRS". These will allow your CURL request to follow the redirects of the destination url.