PHP 컬 호출을하려고합니다. 이 호출은 POSTMAN에서 작동하며 다음과 같이 표시됩니다.PHP 컬 호출을 통해 데이터 가져 오기
URL Endpoint: https://api.sb.example.com/v1/resource/identifier
Headers:
Content Type: application/json
Authorization : Bearer AccessTokenValue
HTTP Protocol : GET
이 호출은 유효한 JSON 응답을 반환합니다. 이제 PHP를 사용하여 동일한 작업을 수행 할 때 응답을 얻을 수 없습니다. 여기 내 PHP 컬 호출은 다음과 같습니다
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sb.example.com/v1/resource/identifier");
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type : application/json',
'Authorization : Bearer AccessTokenValue'
));
$data = curl_exec($ch);
print_r($data);
curl_close($ch);
PHP를 통해이 호출은 나에게 오류 제공 : 코드에 대한
HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
모든 아이디어/제안? curl_exec 전에