PHP SOAP関数+Live Search API

投稿日 : 2008年2月6日 23:23

 コード名「Rome」という新しいLive Searchのリリースを計画しているようです。でもそんなの(略)。

 以前、PEARのSOAPパッケージを使ってLive Search APIを利用するコードを書きましたが、PHP5 SOAP関数を使うバージョンも書いてみました。SOAP関数の情報も少ないですね。

 $clientの__getTypesメソッドの戻り値を取得することで どのような型がWSDLから作られたかわかりますので、その型名を使い連想配列を作ります。省略可能な項目も一部指定してやらないと無いって怒られました。

<?php
$client = null;

try {
    $client = new SoapClient('http://soap.search.msn.com/webservices.asmx?wsdl');

    $sourceRequest = array(
    	'Source'       => 'Web',
    	'Offset'       => 0,
    	'Count'        => 1,
    	'ResultFields' => 'All');
    
    $searchRequest = array(
    	'AppID'       => 'Your Application ID',
    	'Query'       => 'Live Search API',
    	'CultureInfo' => 'ja-JP',
    	'SafeSearch'  => 'Moderate',
    	'Flags'       => 'None',
    	'Requests'    => array($sourceRequest));
    
    $searchResponse = $client->Search(array('Request' => $searchRequest));

    echo '<pre>' . htmlspecialchars(print_r($searchResponse, true)) . '</pre>';
    
} catch (SoapFault $soapEx) {
    echo $soapEx;

} catch (Exception $ex) {
    echo $ex->getMessage();
}
?>

フィードバック

# xDzSzavAHGuh

2011/12/27 20:11 by http://www.towelwholesaler.com/
I read and feel at home. Thanks the creators for a good resource..!

# QONPEFlGicJpQIBRR

2011/12/29 21:19 by http://www.healthinter.org/health/page/abilify.php
Current blog, fresh information, I read it from time to time!!...

# BrMWmqPUlOpEzt

2012/01/07 13:01 by http://www.luckyvitamin.com/m-601-source-naturals
I subscribed to RSS, but for some reason, the messages are written in the form of some hieroglyph (How can it be corrected?!...
コメントの入力
タイトル
名前
Url
コメント