Php tạo api gửi url lên bing search
Dưới đây là đoạn code mới nhất giúp SEOer submit url lên máy tìm kiếm bing :
$url = 'https://ssl.bing.com/webmaster/api.svc/json/SubmitUrlbatch?apikey=key_bing';
$headers = array(
'Content-Type: application/json; charset=utf-8'
);
$data = array(
'siteUrl' => 'https://domain.com',
'urlList' => array(
'https://domain.com/kid.html',
)
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
echo 'Lỗi không gửi được';
$error = curl_error($ch);
// Handle the error
} else {
echo 'Gửi url thành công';
// Handle the response
echo $response;
}
curl_close($ch);