Вот код PHP, который я использую для вызова API:
Код: Выделить всё
//access token url used for authorization
$url="https://api.home.nest.com/oauth2/access_token?code=".$_GET['pin']."&client_id=".$api_key."&client_secret=".$secret_key."&grant_type=authorization_code";
$ch = curl_init ($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
//https
curl_setopt($ch, CURLOPT_SSLVERSION,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST,true);
//to have headers in response
curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec ($ch);
if($result){
echo "Result : " .$result;
}else{
echo curl_error($ch);
}
Код: Выделить всё
Result : HTTP/1.1 200 Connection established HTTP/1.1 400 BAD_REQUEST Content-Length: 0 Connection: Close
РЕДАКТИРОВАТЬ: Сгенерированный URL-адрес ($url) отлично работает с HTTPRequester (надстройка Firefox), поэтому проблема, скорее всего, возникает из-за самого запроса на завивку.
Заранее спасибо.>
Подробнее здесь: https://stackoverflow.com/questions/279 ... horization
Мобильная версия