I’m trying to use Live Search 2.0 but even a simple example doesn’t seem to work. Microsoft only has example code for 1.1 and they’re not giving out AppIDs for that version.
Here’s what I’m trying with:
<?php $server = new SoapClient('http://soap.search.msn.com/webservices.asmx?wsdl'); class Search { public $Request; } class SearchRequest { public $AppID; public $Query; public $CultureInfo; public $SafeSearch; public $Flags; public $Location; public $Requests; } class SourceRequest { public $Source; public $Offset; public $Count; public $FileType; public $SortBy; public $ResultFields; public $SearchTagFilters; } $searchRequest = new SourceRequest(); $searchRequest->Source = 'Web'; $searchRequest->Offset = 0; $searchRequest->Count = 5; $searchRequest->ResultFields = 'All SearchTagsArray'; $request = new SearchRequest(); $request->AppID = '...'; $request->Query = 'Bill Gates'; $request->CultureInfo = 'en-US'; $request->SafeSearch = 'Off'; $request->Flags = ''; $request->Requests = array($searchRequest); $search = new Search(); $search->Request = $request; $server->Search($search); ?>
AppID is correctly specified in the code: I just erased it from here. I’m getting the following error:
Array ( [0] => SearchResponse Search(Search $parameters) ) Fatal error: Uncaught SoapFault exception: [soapenv:Client] Client Error in /Users/thardas/Sites/vt9/widgets/ms_livesearch.php:41 Stack trace: #0 [internal function]: SoapClient->__call('Search', Array) #1 /Users/thardas/Sites/vt9/widgets/ms_livesearch.php(41): SoapClient->Search(Object(SearchRequest)) #2 /Users/thardas/Sites/vt9/index.php(23): include('/Users/thardas/...') #3 {main} thrown in /Users/thardas/Sites/vt9/widgets/ms_livesearch.php on line 41
You could begin by using the proper soap api url for 2.0. It’s now ‘http://api.search.live.net/search.wsdl?AppID=YourAppId‘ taken from (http://msdn.microsoft.com/en-us/library/dd250965.aspx )
You can also use the new JSON api with php.
And finally theres a xml api you can look up at the msdn link as well and it can be fetched essentially the same way as the json you just need to decode it differently.