Bing URL Submission API using Laravel / PHP

  • 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
  • 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
]
]);
"{"ErrorCode":14,"Message":"ERROR!!! NotAuthorized"}"

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store