$result=YandexApi::postKeys("https://api.webmaster.yandex.net/v3/user/".$yandex_user_id."/hosts/",
array(
'host_url'=> 'https://domain.ru'
),
array('Authorization: OAuth '.$yandex_token, 'Content-type: application/json')
);
function postKeys($url,$peremen,$headers) {
$post_arr=array();
foreach ($peremen as $key=>$value) {
$post_arr[]=$key."=".$value;
}
$data=implode('&',$post_arr);
$handle=curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$response=curl_exec($handle);
$code=curl_getinfo($handle, CURLINFO_HTTP_CODE);
return array("code"=>$code,"response"=>$response);
}
в итоге выдает ошибку
Array
(
[code] => 400
[response] => {"error_code":"ENTITY_VALIDATION_ERROR","error_message":"Cannot parse request entity"}
)
Что не так?