我正在尝试使用Live Search 2.0,但即使是简单的示例似乎也无法工作。微软仅提供1.1版本的示例代码,而他们不提供该版本的AppID。
这是我正在尝试的:
<?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在代码中已正确指定:我只是从这里擦掉了它。我遇到了以下错误:
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