cvs: pear /Services_Hatena/Hatena Asin.php Autolink.php Bookmark.php Bookmarknum.php Exist.php Foto.php Search.php Similar.php

From: Date: Wed, 22 Mar 2006 16:07:22 +0000
Subject: cvs: pear /Services_Hatena/Hatena Asin.php Autolink.php Bookmark.php Bookmarknum.php Exist.php Foto.php Search.php Similar.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-39242@lists.php.net to get a copy of this message
makoto Wed Mar 22 16:07:22 2006 UTC Added files: /pear/Services_Hatena/Hatena Asin.php Autolink.php Bookmark.php Bookmarknum.php Exist.php Foto.php Search.php Similar.php Log: Initial commit

http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Asin.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Asin.php +++ pear/Services_Hatena/Hatena/Asin.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Asin class * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Asin.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Asin * * Interface for Hatena::Bookmark's getAsinCount XML-RPC API * This class make a call to 'bookmark.getAsinCount' method of the Hatena Web * Services. The arguments is ASIN Code to get a number of registrations * in Hatena. * (ASIN Code : Amazon Standard Identification Number) * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Asin extends Services_Hatena { /** * execute function * * @param string $asin ASIN Code * @return string number of collectioned asin */ function execute($asin) { require_once 'XML/RPC.php'; $params = new XML_RPC_Value($asin,'string'); $msg = new XML_RPC_Message('bookmark.getAsinCount', array($params)); $client = new XML_RPC_Client('/xmlrpc', $this->bookmark_url, 80); $response = $client->send($msg); if (!$response->faultCode()) { $r = $response->value(); $r = $r->scalarval(); return $r[$asin]->me['int']; } else { return PEAR::raiseError('missing the result.'); } } } ?> http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Autolink.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Autolink.php +++ pear/Services_Hatena/Hatena/Autolink.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Autolink * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Autolink.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Autolink * * Interface for Hatena::Diary's setKeywordLink XML-RPC API * This class make a call to 'hatena.setKeywordLink' method of the Hatena Web * Services. The arguments is keyword to get autolinked keyword. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Autolink extends Services_Hatena { /** * To store parameter * * @see makeParams */ var $parameters; /** * execute * * return autolinked keyword * * @param string $keyword keyword * @return string autolinked keyword */ function execute($keyword) { require_once 'XML/RPC.php'; /** * @note * I hope the keyword is encoded by "UTF-8". * $keyword = mb_convert_encoding($keyword, "UTF-8", "ASCII,JIS,UTF-8,EUC-JP,SJIS"); */ $params = $this->makeParams($keyword); $msg = new XML_RPC_Message('hatena.setKeywordLink', array($params)); $client = new XML_RPC_Client('/xmlrpc', $this->diary_url, 80); $response = $client->send($msg); if (!$response->faultCode()) { $r = $response->value(); $r = $r->scalarval(); $r = html_entity_decode($r); return $r; } else { return PEAR::raiseError('missing the result.'); } } /** * To set score * * You can set score.(You can omit it.) * * @param string $score score */ function setScore($score) { if ($score < 0 || 50 < $score) { return; } $this->parameters['score'] = $score; } /** * To set target * * You can set target.(You can omit it.) * * @param string $target target */ function setTarget($target) { $this->parameters['a_target'] = $target; } /** * To set class * * You can set class.(You can omit it.) * * @param string $class class */ function setClass($class) { $this->parameters['a_class'] = $class; } /** * To set category * * You can set category.(You can omit it.) * * @param string $cname Category */ function setCname($cname) { if (!(is_array($cname))) { $cname = array($cname); } $this->parameters['cname'] = $cname; } /** * To make parameter * * @param string $keyword keyword */ function makeParams($keyword) { $score = isset($this->parameters['score']) ? $this->parameters['score'] : 0; $a_target = isset($this->parameters['a_target']) ? $this->parameters['a_target'] : '_blank'; $a_class = isset($this->parameters['a_class']) ? $this->parameters['a_class'] : 'keyword'; $cname = array(); if (isset($this->parameters['cname'])) { foreach ($this->parameters['cname'] as $c) { $xml_rpc_value = new XML_RPC_Value($c,'string'); array_push($cname, $xml_rpc_value); } } $params = new XML_RPC_Value(array( 'body' => new XML_RPC_Value($keyword , 'string'), 'score' => new XML_RPC_Value($score , 'int'), 'cname' => new XML_RPC_Value($cname , 'array'), 'a_target' => new XML_RPC_Value($a_target, 'string'), 'a_class' => new XML_RPC_Value($a_class , 'string') ), 'struct'); return $params; } } ?> http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Bookmark.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Bookmark.php +++ pear/Services_Hatena/Hatena/Bookmark.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Bookmark * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka, shoma * @copyright 2006 Makoto Tanaka, shoma * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Bookmark.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Bookmark * * Interface for Hatena::Bookmark's Atom API * This class serves get, add, edit and delete method * for your bookmark to Hatena::Bookmark. * * @category Services * @package Services_Hatena * @author Makoto Tanaka, shoma * @copyright 2006 Makoto Tanaka, shoma * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Bookmark extends Services_Hatena { /** * To store HTTP_Request object. * * @see Services_Hatena_Bookmark */ var $http; /** * constructer * * create HTTP_Request object */ function Services_Hatena_Bookmark() { $this->http = new HTTP_Request(); $this->addurl = 'http://' . $this->bookmark_url . '/atom/post'; $this->editurl = 'http://' . $this->bookmark_url . '/atom/edit'; } /** * To add bookmark * * @param string $url URL * @param string $comment comment */ function add_bookmark($url, $comment) { $wsse = $this->getWSSEAuth(); $rawdata = ' <entry xmlns="http://purl.org/atom/ns#"> <title>PAGE\'S TITLE</title> <link rel="related" type="text/html" href="'.$url.'" /> <summary type="text/plain">'.$comment.'</summary> </entry>'; $this->setHeader(HTTP_REQUEST_METHOD_POST, $this->addurl); $this->http->addRawPostData($rawdata); return $this->http->sendRequest(); // if you failed, you will be able to see PEAR::isError } /** * To get bookmark title * * @param string $eid hatena bookmark id */ function get_bookmark($eid) { $this->setHeader(HTTP_REQUEST_METHOD_GET, $this->editurl . '/' . $eid); $res = $this->http->sendRequest(); $local_result = $this->http->getResponseBody(); $matches = array(); $pattern = '/<title>(.*)<\/title>/'; preg_match($pattern, $local_result, $matches); if (isset($matches[1])) { return $matches[1]; } else { return PEAR::raiseError('missing the result.'); } } /** * TO edit bookmark title * * @param string $eid hatena bookmark id * @param string $title title * @param string $comment comment */ function edit_bookmark($eid, $title, $comment) { $rawdata = ' <entry xmlns="http://purl.org/atom/ns#"> <title>'.$title.'</title> <summary type="text/plain">'.$comment.'</summary> </entry>'; $this->setHeader(HTTP_REQUEST_METHOD_PUT, $this->editurl . '/' . $eid); $this->http->addRawPostData($rawdata); return $this->http->sendRequest(); // if you failed, you will be able to see PEAR::isError } /** * To delete bookmark * * @param string $eid hatena bookmark id */ function delete_bookmark($eid) { $this->setHeader(HTTP_REQUEST_METHOD_DELETE, $this->editurl . '/' . $eid); $this->http->addRawPostData($rawdata); return $this->http->sendRequest(); // if you failed, you will be able to see PEAR::isError } /** * To make header * * @param string $method HTTP Method * @param string $url Request URL */ function setHeader($method, $url) { $this->http->addHeader('Accept', 'application/x.atom+xml, application/xml, text/xml, */*'); $this->http->addHeader('Authorization', 'WSSE profile="UsernameToken"'); $this->http->addHeader('X-WSSE', $this->getWSSEAuth()); $this->http->addHeader('Content-Type', 'application/x.atom+xml'); $this->http->setMethod($method); $this->http->setURL($url); } } ?> http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Bookmarknum.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Bookmarknum.php +++ pear/Services_Hatena/Hatena/Bookmarknum.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Bookmarknum * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Bookmarknum.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Bookmarknum * * Interface for Hatena::Bookmark's getCount XML-RPC API * This class make a call to 'bookmark.getCount' method of the Hatena Web * Services. The arguments is URL to get a number of registrations * in Hatena::Bookmark. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Bookmarknum extends Services_Hatena { /** * execute * * return number of bookmarked * * @param string $url URL * @return integer number of bookmarked */ function execute($url) { require_once 'XML/RPC.php'; $params = new XML_RPC_Value($url, 'string'); $msg = new XML_RPC_Message('bookmark.getCount', array($params)); $client = new XML_RPC_Client('/xmlrpc', $this->bookmark_url, 80); $response = $client->send($msg); if (!$response->faultCode()) { $r = $response->value(); $r = $r->scalarval(); return $r[$url]->me['int']; } else { return PEAR::raiseError('missing the result.'); } } } ?> http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Exist.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Exist.php +++ pear/Services_Hatena/Hatena/Exist.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Exist * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Exist.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Exist * * Interface for Hatena's exist REST API * This class make a method to get Resources of a URL in Hatena Services. * The arguments is URL to get information of registrations in Hatena. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Exist extends Services_Hatena { /** * To send request URL. This will not change. * * @see execute */ var $exist_url = 'http://d.hatena.ne.jp/exist?mode=xml&url='; /** * execute * * @param string $url URL * @return string information */ function execute($url) { require_once 'HTTP/Request.php'; $http = new HTTP_Request(); $req_url = $this->exist_url . $url; $http->setURL($req_url); $http->setMethod(HTTP_REQUEST_METHOD_GET); $res = $http->sendRequest(); $local_result = $http->getResponseBody(); $matches = array(); $pattern = '/<count name="(.*)">(.*)<\/count>/'; preg_match_all($pattern, $local_result, $matches); /** * @note * this is example matches result * [1] => Array ( * [0] => diary * [1] => antenna * [2] => bookmark * ) * [2] => Array ( * [0] => 796 * [1] => 1 * [2] => 577 * ) * * if the information is nothing, i will return null. */ $match_result = array(); if ($matches[1][0] && $matches[2][0]) { $match_result[$matches[1][0]] = $matches[2][0]; } if ($matches[1][1] && $matches[2][1]) { $match_result[$matches[1][1]] = $matches[2][1]; } if ($matches[1][2] && $matches[2][2]) { $match_result[$matches[1][2]] = $matches[2][2]; } return $match_result; } } ?> http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Foto.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Foto.php +++ pear/Services_Hatena/Hatena/Foto.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Foto Life * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Foto.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Foto * * Interface for Hatena::Fotolife's Atom API * This class serves get, add, edit and delete method * for your image file to Hatena::Fotolife. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Foto extends Services_Hatena { /** * To store HTTP_Request Object * * @see Services_Hatena_Foto */ var $http; /** * constructer * * create HTTP_Request object. */ function Services_Hatena_Foto() { $this->http = new HTTP_Request(); $this->addurl = 'http://' . $this->foto_url . '/atom/post'; $this->editurl = 'http://' . $this->foto_url . '/atom/edit'; } /** * To add image * * @param string $image image name * @param string $title image title */ function add_foto($image, $title) { $wsse = $this->getWSSEAuth(); $based_image = base64_encode(file_get_contents($image)); $rawdata = ' <entry xmlns="http://purl.org/atom/ns#"> <title>'.$title.'</title> <content mode="base64" type="image/jpeg">'.$based_image.'</content> </entry>'; $this->setHeader(HTTP_REQUEST_METHOD_POST, $this->addurl); $this->http->addRawPostData($rawdata); return $this->http->sendRequest(); // if you failed, you will be able to see PEAR::isError } /** * To get image title * * @param string $fid hatena foto id */ function get_foto($fid) { $this->setHeader(HTTP_REQUEST_METHOD_GET, $this->editurl . '/'. $fid); $res = $this->http->sendRequest(); $local_result = $this->http->getResponseBody(); $matches = array(); $pattern = '/<title>(.*)<\/title>/'; preg_match($pattern, $local_result, $matches); if (isset($matches[1])) { return $matches[1]; } else { return PEAR::raiseError('missing the result.'); } } /** * To edit image title * * @param string $fid hatena foto id * @param string $title image title */ function edit_foto($fid, $title) { $rawdata = ' <entry xmlns="http://purl.org/atom/ns#"> <title>'.$title.'</title> </entry>'; $this->setHeader(HTTP_REQUEST_METHOD_PUT, $this->editurl . '/' . $fid); $this->http->addRawPostData($rawdata); return $this->http->sendRequest(); // if you failed, you will be able to see PEAR::isError } /** * To delete image * * @param string $fid hatena foto id */ function delete_foto($fid) { $this->setHeader(HTTP_REQUEST_METHOD_DELETE, $this->editurl . '/' . $fid); $this->http->addRawPostData($rawdata); return $this->http->sendRequest(); // if you failed, you will be able to see PEAR::isError } /** * To make header * * @param string $method HTTP Method * @param string $url Request URL */ function setHeader($method, $url) { $this->http->addHeader('Accept', 'application/x.atom+xml, application/xml, text/xml, */*'); $this->http->addHeader('Authorization', 'WSSE profile="UsernameToken"'); $this->http->addHeader('X-WSSE', $this->getWSSEAuth()); $this->http->addHeader('Content-Type', 'application/x.atom+xml'); $this->http->setMethod($method); $this->http->setURL($url); } } ?> http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Search.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Search.php +++ pear/Services_Hatena/Hatena/Search.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Search * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Search.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Search * * Interface for Hatena::Search with OpernSerch. * This class make Search function from Hatena. * The arguments is keyword to get a search result from Hatena. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Search extends Services_Hatena { /** * To store OpenSearch Description Document URI. * * @see Services_Hatena_Search */ var $osxml_url = 'http://search.hatena.ne.jp/osxml'; /** * To store OpenSearch object * * @see Services_Hatena_Search */ var $os = null; /** * constructer * * create OpenSearch object */ function Services_Hatena_Search() { require_once 'Services/OpenSearch.php'; $this->os = new Services_OpenSearch($this->osxml_url); } /** * execute * * @param string $keyword keyword * @return array search result */ function execute($keyword) { /** * @note * I hope the keyword is encoded by "UTF-8". * $keyword = mb_convert_encoding($keyword, "UTF-8", "ASCII,JIS,UTF-8,EUC-JP,SJIS"); */ return $this->os->search($keyword); } /** * To get number of search result * * @return intger number of search result */ function getTotalSearchResult() { return $this->os->getTotalResults(); } /** * To set start page for search * * @param integer $p page number */ function setStartPage($p) { $this->os->setStartPage($p); } /** * To get start page for search * * @return intger page number */ function getStartPage() { return $this->os->getStartPage(); } /** * Retrieves the currently set entry count of per page. * * @return intger entry count */ function getCount() { return $this->os->getCount(); } /** * To get previous page number * * @return page number */ function getPrevPage() { $s = $this->getStartPage(); $r = $this->getTotalSearchResult(); $c = $this->getCount(); if ($s >= 2) { return $s - 1; } } /** * To get next page number * * @return page number */ function getNextPage() { $s = $this->getStartPage(); $r = $this->getTotalSearchResult(); $c = $this->getCount(); $c = ( $c != 0 ) ? $c : 1; if (($r / $c) >= $s) { return $s + 1; } } } ?> http://cvs.php.net/viewcvs.cgi/pear/Services_Hatena/Hatena/Similar.php?view=markup&rev=1.1 Index: pear/Services_Hatena/Hatena/Similar.php +++ pear/Services_Hatena/Hatena/Similar.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Similar * * PHP version 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt. If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version CVS: $Id: Similar.php,v 1.1 2006/03/22 16:07:22 makoto Exp $ */ /** * Services_Hatena_Similar * * Interface for Hatena::Diary's getSimilarWord XML-RPC API * This class make a call to 'hatena.getSimilarWord' method of the Hatena Web * Services. The arguments is Keyword to get similar keyword list. * * @category Services * @package Services_Hatena * @author Makoto Tanaka * @copyright 2006 Makoto Tanaka * @license http://www.php.net/license/3_0.txt PHP License 3.0 * @version Release: 0.1.0 */ class Services_Hatena_Similar extends Services_Hatena { /** * execute * * @param string $similar keyword * @return string similar words */ function execute($similar) { require_once 'XML/RPC.php'; /** * @note * I hope the similar keyword is encoded by "UTF-8". * $similar = mb_convert_encoding($similar, "UTF-8", "ASCII,JIS,UTF-8,EUC-JP,SJIS"); */ $params = $this->makeParams($similar); $msg = new XML_RPC_Message('hatena.getSimilarWord', array($params)); $client = new XML_RPC_Client('/xmlrpc', $this->diary_url, 80); $response = $client->send($msg); if (!$response->faultCode()) { $r = $response->value(); $r = $r->scalarval(); $r_array = $r['wordlist']->me['array']; $match_result = array(); foreach ( $r_array as $rs ) { $word = $rs->me['struct']['word']->me['string']; array_push($match_result, $word); } return $match_result; } else { return PEAR::raiseError('missing the class.'); } } /** * To make parameter * * @param string $similar keyword */ function makeParams($similar) { if (!(is_array($similar))) { $similar = array($similar); } $wordlist = array(); foreach ($similar as $s) { $xml_rpc_value = new XML_RPC_Value($s,'string'); array_push($wordlist, $xml_rpc_value); } $params = new XML_RPC_Value(array( 'wordlist' => new XML_RPC_Value($wordlist, 'array'), ), 'struct'); return $params; } } ?>
« previous php.pear.cvs (#39242) next »