示例#1
0
 public function testSpecificHttpClient()
 {
     $client = new Zend_Http_Client();
     $gdata = new Zend_Gdata($client);
     $client2 = $gdata->getHttpClient();
     $this->assertTrue($client2 instanceof Zend_Http_Client, 'Expecting object of type Zend_Http_Client, got ' . (gettype($client) == 'object' ? get_class($client) : gettype($client)));
     $this->assertSame($client, $client2);
 }
示例#2
0
 public function testSpecificHttpClient()
 {
     $client = new Zend_Http_Client();
     $gdata = new Zend_Gdata($client);
     $this->assertSame($client, $gdata->getHttpClient());
 }
 /**
  * retrieves email ids for all the contacts from Gmail and stores in Ofuz DB temprorily.
  *
  * @return void
  * @see Gdata
  */
 function storeGmailEmailsTemprorily()
 {
     global $_SESSION, $_GET;
     $client = $this->client;
     $useremailid = urlencode($_SESSION["uEmail"]);
     // Create a Gdata object using the authenticated Http Client
     $gdata = new Zend_Gdata($client);
     //$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/'.$_SESSION["uEmail"].'%40gmail.com/full');
     $query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/' . $useremailid . '/full');
     $query->setMaxResults(1000);
     try {
         $feed = $gdata->getFeed($query);
         if ($feed) {
             $q_email = new sqlQuery($this->getDbCon());
             foreach ($feed as $entry) {
                 // retrieving emails
                 $extensionElements = $entry->getExtensionElements();
                 foreach ($extensionElements as $extensionElement) {
                     //emails
                     if ($extensionElement->rootNamespaceURI == "http://schemas.google.com/g/2005" && $extensionElement->rootElement == "email") {
                         $attributes = $extensionElement->getExtensionAttributes();
                         if (array_key_exists('address', $attributes)) {
                             if ($attributes['rel']['value'] == "http://schemas.google.com/g/2005#home") {
                                 //$data['em_home'] = $attributes['address']['value'];
                                 $sql_email_ins = "INSERT INTO \n                                                              temp_gmail_emails(email_address)\n                                                              VALUES('" . $attributes['address']['value'] . "')\n                                                            ";
                                 $q_email->query($sql_email_ins);
                             }
                             if ($attributes['rel']['value'] == "http://schemas.google.com/g/2005#work") {
                                 $sql_email_ins = "INSERT INTO \n                                                              temp_gmail_emails(email_address)\n                                                              VALUES('" . $attributes['address']['value'] . "')\n                                                            ";
                                 $q_email->query($sql_email_ins);
                             }
                             if ($attributes['rel']['value'] == "http://schemas.google.com/g/2005#other") {
                                 $sql_email_ins = "INSERT INTO \n                                                              temp_gmail_emails(email_address)\n                                                              VALUES('" . $attributes['address']['value'] . "')\n                                                            ";
                                 $q_email->query($sql_email_ins);
                             }
                         }
                     }
                 }
             }
             $q_email->free();
         }
     } catch (Exception $e) {
         $status_code = $gdata->getHttpClient()->getLastResponse()->getStatus();
         $this->status_code_desc = $this->getStatusDescription($status_code);
     }
 }