Récupération de contact via Zend_Gdata
Bonjour à tous, voila je souhaite récupérer une liste de contact Gmail, j'ai donc réaliser le code suivant, malheureusement (bien entendu...)il ne fonctionne pas, j'obtiens l'erreur suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
Exception information:
Message: Expected response code 200, got 403
Cannot request contacts belonging to another domain (blabla).
Error 403
Stack trace:
#0 C:\wamp\www\quickstart\library\Zend\Gdata.php(219): Zend_Gdata_App->performHttpRequest('GET', 'http://www.goog...', Array, NULL, NULL, NULL)
#1 C:\wamp\www\quickstart\library\Zend\Gdata\App.php(861): Zend_Gdata->performHttpRequest('GET', 'http://www.goog...', Array)
#2 C:\wamp\www\quickstart\library\Zend\Gdata\App.php(754): Zend_Gdata_App->get('http://www.goog...', NULL)
#3 C:\wamp\www\quickstart\library\Zend\Gdata\App.php(205): Zend_Gdata_App->importUrl('http://www.goog...', 'Zend_Gdata_Feed', NULL)
#4 C:\wamp\www\quickstart\library\Zend\Gdata.php(162): Zend_Gdata_App->getFeed('http://www.goog...', 'Zend_Gdata_Feed')
#5 C:\wamp\www\quickstart\library\My\ContactsGetter\Modules\Gmail.php(38): Zend_Gdata->getFeed(Object(Zend_Gdata_Query))
#6 C:\wamp\www\quickstart\application\controllers\IndexController.php(17): My_ContactsGetter_Modules_Gmail->getAllContacts('***', '***')
#7 C:\wamp\www\quickstart\library\Zend\Controller\Action.php(513): IndexController->indexAction()
#8 C:\wamp\www\quickstart\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('indexAction')
#9 C:\wamp\www\quickstart\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#10 C:\wamp\www\quickstart\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#11 C:\wamp\www\quickstart\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#12 C:\wamp\www\quickstart\public\index.php(28): Zend_Application->run()
#13 {main}
Request Parameters:
array (
'controller' => 'index',
'action' => 'index',
'module' => 'default',
) |
Voici le code de ma fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
public function getAllContacts($login, $password)
{
$client = Zend_Gdata_ClientLogin::getHttpClient($login,$password,"cp");
$client->setConfig(array('timeout' => 30));
$response = $client->getLastResponse()->getStatus();
// Si la requete à abouti (oui si response=200)
if ($response == 200)
{
$token = $client->getClientLoginToken();
$gdata = new Zend_Gdata($client);
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/'.$login.'/full');
$query->setMaxResults(1000);
$feed = $gdata->getFeed($query);
//
$xml = new SimpleXMLElement($feed->getXML());
$entries = $xml->children('http://www.w3.org/2005/Atom');
// Pour chaque contact (entry)
foreach ($entries->entry as $entry ) {
$defaults = $entry->children('http://schemas.google.com/g/2005');
$nom = $entry->title;
$mail = $defaults->email->attributes()->address;
$URi = urlencode($entry->link[1]->attributes());
$img = '../../../index.php/image/index/type/gmail/?URi='.$URi.'&token='.$token;
$contacts[] = new Contact($nom, $mail, $img); // on crée un contact
}
return $contacts;
}
} |
Si quelqu'un pouvait m'indiquer mes erreurs je lui en serait très reconnaissant:ccool:
Merci à tous d'avance:aie: