웹에서 php로 /v1/user/access_token_info http code 400 반환 오류나 납니다 ㅠㅠ

---------------------------- 웹에서 php CURL로 호출시 ---------------------------------------

          $curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, "https://kapi.kakao.com/v1/user/access_token_info");
	curl_setopt($curl, CURLOPT_HTTPHEADER,  array("Authorization : Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "Content-type: application/x-www-form-urlencoded;charset=utf-8"));
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
			
	$res = curl_exec($curl);
	$curlinfo = curl_getinfo($curl);
	$status = json_decode($res, true);
	//print_r($status);
	//var_dump($res); //결과값 출력
	print_r(curl_getinfo($curl)); //모든정보 출력
	echo curl_errno($curl); //에러정보 출력
	echo curl_error($curl); //에러정보 출력
	
	curl_close($curl);

---------------------- 리턴값 ---------------------------
Array
(
[url] => https://kapi.kakao.com/v1/user/access_token_info
[content_type] => text/html; charset=iso-8859-1
[http_code] => 400
[header_size] => 164
[request_size] => 209
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.042056
[namelookup_time] => 0.012382
[connect_time] => 0.014823
[pretransfer_time] => 0.039593
[size_upload] => 0
[size_download] => 3
[speed_download] => 71
[speed_upload] => 0
[download_content_length] => 3
[upload_content_length] => -1
[starttransfer_time] => 0.042033
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 203.133.166.33
[certinfo] => Array ( )
[primary_port] => 443
[local_ip] => 110.10.189.25
[local_port] => 33724
)

---------------------- ssh에서 명령어로 실행시에는 정상적으로 값을 반환합니다.
test@q552-0284:~$ curl -v -X GET https://kapi.kakao.com/v1/user/access_token_info \

-H “Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
Note: Unnecessary use of -X or --request, GET is already inferred.

  • Trying 27.0.237.16…
  • Connected to kapi.kakao.com (27.0.237.16) port 443 (#0)
  • found 173 certificates in /etc/ssl/certs/ca-certificates.crt
  • found 694 certificates in /etc/ssl/certs
  • ALPN, offering http/1.1
  • SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
  • server certificate verification OK
  • server certificate status verification SKIPPED
  • common name: *.kakao.com (matched)
  • server certificate expiration date OK
  • server certificate activation date OK
  • certificate public key: RSA
  • certificate version: #3
  • subject: C=KR,ST=Jeju-do,L=Jeju-si,O=Kakao Corp.,CN=*.kakao.com
  • start date: Wed, 11 Nov 2015 00:00:00 GMT
  • expire date: Fri, 10 Nov 2017 23:59:59 GMT
  • issuer: C=US,O=thawte, Inc.,CN=thawte SSL CA - G2
  • compression: NULL
  • ALPN, server did not agree to a protocol

GET /v1/user/access_token_info HTTP/1.1
Host: kapi.kakao.com
User-Agent: curl/7.47.0
Accept: /
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

< HTTP/1.1 200 OK
< Date: Mon, 12 Jun 2017 09:20:18 GMT
< Server: Apache
< Content-Type: application/json;charset=UTF-8
< Content-Length: 43
<

  • Connection #0 to host kapi.kakao.com left intact
    {“id”:xxxxxxxxx,“expiresInMillis”:12568431}

자답 :
Authorization : Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", “Content-type: application/x-www-form-urlencoded;charset=utf-8”
에서 공백을 지우고
Authorization:Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", “Content-type:application/x-www-form-urlencoded;charset=utf-8”
했더니 정상적인 값을 리턴받음

1개의 좋아요