Quantcast
Channel: birghtyoursite » SEO Friendly
Viewing all articles
Browse latest Browse all 4

php get bing indexed pages

$
0
0

when use php to get the bing indexed pages,most ways use crawl the bing pages,i have compared the value with bing.com result,it have big difference.Bing already provide api,so lets go step and step to use php get bing indexed pages number via bing api.

Register to get bing api key

First,we need a register at https://datamarket.azure.com, then sign in.Then sign up for the Bing Search API – Web Results Only. For normal user just choose the free plan “5,000 Transactions/month”.
After this done,go to My Account->ACCOUNT KEYS

just use the default like the screenshot is fine.

php codes to get bing indexed page

function getBingIndexedPages($url)
{
   $accountKey ='your key';  
 
   $ServiceRootURL =  'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/';
 
   $WebSearchURL = $ServiceRootURL . 'Composite?$format=json&Query=';
 
	$context = stream_context_create(array(
			'http' => array(
				'request_fulluri' => true,
				'header'  => "Authorization: Basic " . base64_encode($accountKey . ":" . $accountKey)
			)
		));
	 $key="site:$url"; 
	 $request = $WebSearchURL . urlencode( '\'' .$key. '\''); 
 
	$response = file_get_contents($request, 0, $context);
 
	$jsonobj = json_decode($response);
 
 
	return  $jsonobj->d->results[0]->WebTotal;
}

Notice :

  1. 1.Please take care that “urlencode( ‘\” .$key. ‘\”)” you must have single quotes for the search keyword.
  2. 2.Your php versin must >= 5.0 ,so file_get_contents can support Added context.

Bing api difference with bing.com

I have did many tests with this api data,some are exactly same like the bing.com when the indexed numbers is lower. Check with a site which have a big bing indexed numbers,after you go to page 5,you will see the indexed number changed and have big difference with the top 4 pages,this one its not like the google,google keep indexed numbers not changed for all the pages.So i think the number from bing api is the exactly bing indexed pages,the bing.com results is a valuation when it’s a big number.Also the api number is close to the bing.com reulst,at least it’s closer than the number which got by crawl the page .


Viewing all articles
Browse latest Browse all 4

Trending Articles