【发布时间】:2020-05-08 05:10:26
【问题描述】:
我想在 PHP 中对以下请求进行 cURL:
curl --location --request GET 'xxx.xxxxxad.com/api/rest/issues?project_id=4' -H 'Authorization:xxxxxxxxxxxxxxxxxxxxxxxxxxxHTb'
我实现的代码是:
<?php
$url = "xxx.xxxxxad.com/api/rest/issues?project_id=4";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, array('Authorization:xxxxxxxxxxxxxxxxxxxxxxxxxxxHTb'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
?>
我找不到在请求中包含 --location 的方法,否则无法获取数据。
【问题讨论】:
-
你的问题不够清楚。请检查您使用的第一句话。
-
阅读
--location的作用,然后阅读 PHP curl_setopt 的手册页,并尝试找出等价物是什么……?你可能想要CURLOPT_FOLLOWLOCATION -
也去改变你的访问密钥,因为对于那些真的想要或者只是真的无聊的人来说应该不难找出您正在使用的域,现在他们有了您的访问密钥。 (编辑你的帖子是不够的 - 所以有编辑历史)