CURL和Postman中相同的GET请求有不同的响应

时间:2016-12-08 04:12:34

标签: curl postman php-curl

我一直在尝试重构我在PHP CURL中使用POSTMAN进行的API调用(以及CLI中的CURL)。

以下请求适用于Postman:

enter image description here

......我收到200回复​​。

但是当我在PHP中使用以下内容时:

def printDS[T](ds:Dataset[T]): Unit = {
  ds.show()
}

......我得到了401。

与CLI中的CURL相同:

<?PHP
$curl = curl_init();
$curlopt=array();
$curlopt[CURLOPT_URL] ='https://familysearch.org/platform/tree/persons/LVDH-ZZT/families.json';
$curlopt[CURLOPT_RETURNTRANSFER] = 1;
$curlopt[CURLOPT_TIMEOUT] = 12;
$curlopt[CURLOPT_FOLLOWLOCATION] = 0;
$curlopt[CURLOPT_FAILONERROR] = 0;
$curlopt[CURLOPT_SSL_VERIFYPEER] = 1;
$curlopt[CURLOPT_VERBOSE] = 0;

$headers = array();
$headers[] = 'Authorization: BearerUSYS79A3702777********************';
$curlopt[CURLOPT_HTTPHEADER] = $headers;

$curlopt[CURLOPT_CUSTOMREQUEST] = 'GET';
curl_setopt_array($curl,$curlopt);

echo curl_exec($curl);
?>

有人有什么想法吗?请求似乎与我完全相同。

顺便说一句,我已经从与邮差请求相同的IP地址发送了它们。

更多信息 根据@hanshenrik请求,这里是详细的CURL输出:

curl -H "Authorization: BearerUSYS79A37027774***********************" \
https://familysearch.org/platform/tree/persons/LVDH-ZZT/families.json

0 个答案:

没有答案
相关问题