Answer the question
In order to leave comments, you need to log in
Bulk adding sites to Yandex.Webmaster, 400 error when adding. What's wrong?
$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);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question