If you’re finding this post, you’re probably frustrated with how poor Bing’s documentation for their Submission API is. Google’s Indexing API on the other hand is quite good. Both of these Indexing APIs help you inform search engines about new or updated content on your website.
- You will need an API key for Webmasters so go to Settings -> API access -> API Key — copy this and keep it handy
- Grab the endpoint for the Submission API from here — At this point of writing, it’s set to accept a POST request for the following endpoint with the data object
POST /webmaster/api.svc/json/SubmitUrlbatch?apikey=sampleapikeyEDECC1EA4AE341CC8B6 HTTP/1.1
Content-Type: application/json; charset=utf-8
Host: ssl.bing.com{
"siteUrl":"http://yoursite.com",
"urlList":[
"http://yoursite.com/url1",
"http://yoursite.com/url2",
"http://yoursite.com/url3"
]
}
- With Laravel, if you’re using the HTTP client — it’s as simple as this
$http = \Http::post("https://www.bing.com/webmaster/api.svc/json/SubmitUrlbatch?apikey=" . $apiKey,
[
"siteUrl" => $siteUrl,
"urlList" => $urlList
]
);echo $http->status(); //to make sure it's all ok
echo $http->body(); //to check the body of response
- $apiKey — that you copied earlier. Ideally from a config file or your .env file
- $siteUrl refers to the main domain that you got the API key for — you can usually see this on the top left of the Bing
- $urlList is a simple array containing the list of URLs you want to submit (since we’re submitting URL’s in batch, this makes it much easier)
- With Guzzle, it’s pretty similar too
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://www.bing.com/webmaster/api.svc/json/SubmitUrlbatch?apikey=" . $apiKey', [
'form_params' => [
"siteUrl" => $siteUrl,
"urlList" => $urlList
]
]);
Things should go ok unless you’re like me and face a simple, funny (weird) message like this
"{"ErrorCode":14,"Message":"ERROR!!! NotAuthorized"}"
It just indicates that $siteUrl does not match the proper URL in Bing, change it and you should be good to go.