View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Service_Google
{zone-data}

{zone-data:proposer-list}
[aissam AT yahoo|mailto:aissam@yahoo.com]
{zone-data}

{zone-data:revision}
0.1 - 8 June 2006: First Version
{zone-data}

{zone-data:overview}
Zend_Service_Google will offers a simple and standard interface for dealing with Google's Service

{zone-data}

{zone-data:references}
* [Google's API|http://code.google.com/apis.html]
{zone-data}

{zone-data:requirements}
* PHP 5.1.4 (with SOAP enabled)
{zone-data}

{zone-data:dependencies}
* Zend_Service_Exception
* Zend_HttpClient
* Zend_Feed
{zone-data}

{zone-data:operation}

Zend_Service_Google will offer two simple methods (getService and callService).
It's organised by plugins-like system, so any additional service could be easily
added. Each plugin will be responsable for one specific Google API,
and will take care for dealing with a the google service :
connect, send query, get/parse result, and return it in an easy to use format
(object, array, string or XML)
{zone-data}

{zone-data:class-list}

For advanced users:

* Zend_Service_Google
* Zend_Service_Google_AGMailAtom
* Zend_Service_Google_ASearch
* Zend_Service_Google_AAnotherService
(one classe for each API: format Zend_Service_Google_A<nameOfApi>)

For "no time to RTFM" users ;)

* Zend_Service_Google_Mail
* Zend_Service_Google_Search
* Zend_Service_Google_Spelling
* Zend_Service_Google_Cache
{zone-data}

{zone-data:use-cases}

||UC-01||
Simplest Way
{code}
$gMail=new Zend_Service_Google_Mail($login,$password);
$mails=$gMail->getNew();

$gSearch=new Zend_Service_Google_Search($lincenceKey);
$searchResult=$gSearch->doSearch($keyword);

$gSpell=new Zend_Service_Google_Spelling($lincenceKey);
$correctWord=$gSpell->suggest($incorrectWord);

$gCache=new Zend_Service_Google_Cache($lincenceKey);
$cacheContent=$gCache->getContent($url);
$cachedDOM=$gCache->getDOMContent($url);
{code}

||UC-02||
Unified Way
{code}
$g=new Zend_Service_Google($lincenceKey);
$result=$g->callService('nameOfService', $data1,$data2...);
{code}

||UC-03||
Advanced Way (need little knownledge for Google's API or Zend_Service_Google's API)

{code}
$g=new Zend_Service_Google();

$searchObj=$g->getService('search');
$searchObj->setLicenceKey($licenceKey);
$searchResult= $searchObj->doGoogleSearch($keyword);
$spellResult = $searchObj->doSpellingSuggestion($keyword);
$cachResult = $searchObj->doGetCachedPage($url);

$gMailObj=$g->getService('mail');
$gMailObj->setAuth($login,password);
$mailsArray=$gMailObj->getNewMails();
{code}

{zone-data}

{zone-data:skeletons}
{code}
Class Zend_Service_Google {

/* Services provide a list indexed by aliases */
private $services=array(
'search' =>array('class'=>'Search', 'method'=>'doGoogleSearch'),
'spellCheck' =>array('class'=>'Search', 'method'=>'doSpellingSuggestion'),
'serviceName' =>array('class'=>'AnotherGoogleAPIClass','method'='method')
//...
);

/**
* Construct a Google main service
*
* @param string (optional) licence Key
* @param string (optional) specific google service's options
*/
public function __construct($licenceKey = null,$otherServicesOptions=null) {
}

/**
* Get a Specific Service Object
*
* @param string ServiceName
* @param string (optional) Service init Arguments
* @return object Specific Service's Object
*/
public function getService($serviceName,$args=null) {
// return object of a specific service (if it's already loaded)
// or create a new one (using $services)
}

/**
* Call a Service using it's name
*
* @param string ServiceName
* @param array Arguments usually input data requested by service
* @return mixed Service Call Result (search result, spellcheck, cached page content, ...)
*/
public function callService($serviceName) {
// getService(name) and call the corresponding method described in $services
}

}
{code}

{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>