curl을 사용하는 Google 계정에 대해 아래의 post 메소드를 사용하고 있지만 invalid_request 오류가 발생합니다. 여기 POST에서 CURL을 사용하는 POST가 잘못된 요청을합니다. 오류
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=4/ux5gNj-_mIu4DOD_gNZdjX9EtOFf&
client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&
client_secret=CENSORED&
redirect_uri=http://localhost/oauth2callback&
grant_type=authorization_code
는 컬
$text ='test';
$URL = "https://accounts.google.com/o/oauth2/token";
$header = array(
"POST /o/oauth2/token HTTP/1.1",
"Host: accounts.google.com",
"Content-type: application/atom+xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"code=[my_code]&client_id=[my_client_id]&client_secret=[my_client_secret]& redirect_uri=http://localhost/curl_resp.php&grant_type=authorization_code",
"Content-length: ".strlen($text),
);
$xml_do = curl_init();
curl_setopt($xml_do, CURLOPT_URL, $URL);
curl_setopt($xml_do, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($xml_do, CURLOPT_TIMEOUT, 10);
curl_setopt($xml_do, CURLOPT_RETURNTRANSFER, true);
curl_setopt($xml_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($xml_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($xml_do, CURLOPT_POST, false);
curl_setopt($xml_do, CURLOPT_POSTFIELDS, $text);
curl_setopt($xml_do, CURLOPT_HTTPHEADER, $header);
내 PHP 코드 그리고 잘못된 요청 오류 요청에 대한 응답이 실제로 문제의 매우 읽을 수있는 설명을 포함
당신이 당신의 PHP 코드를 추가 할 수 있을까요? – Travesty3
서버로 보내는 데이터에 POST 본문의 '&'문자 다음에 오는 새 줄이 있습니까? 왜냐하면 그들은해서는 안되기 때문입니다 ... – DaveRandom
PHP 코드는 읽기가 어렵다고 말하는 것이 아니라 완전한 것으로 보입니다. 질문을 편집하고 거기에 PHP를 코드 블록으로 추가하십시오. – lanzz