Example #1
0
 public function getWebmastertoolsSitesAction()
 {
     $credentials = $this->getWebmastertoolsCredentials();
     if ($credentials) {
         $username = $credentials["username"];
         $password = $credentials["password"];
     }
     if ($this->_getParam("username") && $this->_getParam("password")) {
         $username = $this->_getParam("username");
         $password = $this->_getParam("password");
     }
     try {
         $client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, "sitemaps", Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"));
         $service = new Zend_Gdata($client);
         $data = $service->getFeed("https://www.google.com/webmasters/tools/feeds/sites/");
         foreach ($data->getEntry() as $e) {
             $verification = "";
             // get verification filename
             foreach ($e->getExtensionElements() as $d) {
                 $a = $d->getExtensionAttributes();
                 if ($a["type"]["value"] == "htmlpage") {
                     $verification = $d->getText();
                     break;
                 }
             }
             $sites[] = array("profile" => (string) $e->getTitle(), "verification" => $verification);
         }
         $this->_helper->json(array("data" => $sites));
     } catch (Exception $e) {
         $this->_helper->json(false);
     }
 }
    public function testNormalOriginalEventShouldHaveNoExtensionElements() {
        $this->originalEvent->href = "http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite";
        $this->originalEvent->id = "abcdef123456789";
        
        $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $this->originalEvent->href);
        $this->assertEquals("abcdef123456789", $this->originalEvent->id);
                
        $this->assertEquals(0, count($this->originalEvent->extensionElements));
        $newOriginalEvent = new Zend_Gdata_Extension_OriginalEvent(); 
        $newOriginalEvent->transferFromXML($this->originalEvent->saveXML());
        $this->assertEquals(0, count($newOriginalEvent->extensionElements));
        $newOriginalEvent->extensionElements = array(
                new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
        $this->assertEquals(1, count($newOriginalEvent->extensionElements));
        $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent->href);
        $this->assertEquals("abcdef123456789", $newOriginalEvent->id);

        /* try constructing using magic factory */
        $gdata = new Zend_Gdata();
        $newOriginalEvent2 = $gdata->newOriginalEvent();
        $newOriginalEvent2->transferFromXML($newOriginalEvent->saveXML());
        $this->assertEquals(1, count($newOriginalEvent2->extensionElements));
        $this->assertEquals("http://www.google.com/calendar/feeds/nobody@gmail.com/private/composite", $newOriginalEvent2->href);
        $this->assertEquals("abcdef123456789", $newOriginalEvent2->id);
    }
Example #3
0
 public function testNormalFeedLinkShouldHaveNoExtensionElements()
 {
     $this->feedLink->href = "http://www.google.com/calendar/feeds/default/private/full";
     $this->feedLink->rel = "via";
     $this->feedLink->countHint = "5";
     $this->feedLink->readOnly = "false";
     $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $this->feedLink->href);
     $this->assertEquals("via", $this->feedLink->rel);
     $this->assertEquals("5", $this->feedLink->countHint);
     $this->assertEquals("false", $this->feedLink->readOnly);
     $this->assertEquals(0, count($this->feedLink->extensionElements));
     $newFeedLink = new Zend_Gdata_Extension_FeedLink();
     $newFeedLink->transferFromXML($this->feedLink->saveXML());
     $this->assertEquals(0, count($newFeedLink->extensionElements));
     $newFeedLink->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newFeedLink->extensionElements));
     $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink->href);
     $this->assertEquals("via", $newFeedLink->rel);
     $this->assertEquals("5", $newFeedLink->countHint);
     $this->assertEquals("false", $newFeedLink->readOnly);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newFeedLink2 = $gdata->newFeedLink();
     $newFeedLink2->transferFromXML($newFeedLink->saveXML());
     $this->assertEquals(1, count($newFeedLink2->extensionElements));
     $this->assertEquals("http://www.google.com/calendar/feeds/default/private/full", $newFeedLink2->href);
     $this->assertEquals("via", $newFeedLink2->rel);
     $this->assertEquals("5", $newFeedLink2->countHint);
     $this->assertEquals("false", $newFeedLink2->readOnly);
 }
Example #4
0
 public function testNormalReminderShouldHaveNoExtensionElements()
 {
     $this->reminder->days = "12";
     $this->reminder->minutes = "64";
     $this->reminder->absoluteTime = "2007-06-19T12:42:19-06:00";
     $this->reminder->method = "email";
     $this->reminder->hours = "80";
     $this->assertEquals("12", $this->reminder->days);
     $this->assertEquals("64", $this->reminder->minutes);
     $this->assertEquals("2007-06-19T12:42:19-06:00", $this->reminder->absoluteTime);
     $this->assertEquals("email", $this->reminder->method);
     $this->assertEquals("80", $this->reminder->hours);
     $this->assertEquals(0, count($this->reminder->extensionElements));
     $newReminder = new Zend_Gdata_Extension_Reminder();
     $newReminder->transferFromXML($this->reminder->saveXML());
     $this->assertEquals(0, count($newReminder->extensionElements));
     $newReminder->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newReminder->extensionElements));
     $this->assertEquals("12", $newReminder->days);
     $this->assertEquals("64", $newReminder->minutes);
     $this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder->absoluteTime);
     $this->assertEquals("email", $newReminder->method);
     $this->assertEquals("80", $newReminder->hours);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newReminder2 = $gdata->newReminder();
     $newReminder2->transferFromXML($newReminder->saveXML());
     $this->assertEquals(1, count($newReminder2->extensionElements));
     $this->assertEquals("12", $newReminder2->days);
     $this->assertEquals("64", $newReminder2->minutes);
     $this->assertEquals("2007-06-19T12:42:19-06:00", $newReminder2->absoluteTime);
     $this->assertEquals("email", $newReminder2->method);
     $this->assertEquals("80", $newReminder2->hours);
 }
 public function testNormalEntryLinkShouldHaveNoExtensionElements()
 {
     $this->entryLink->href = "http://gmail.com/jo/contacts/Bob";
     $this->entryLink->rel = "self";
     $this->entryLink->readOnly = "false";
     $this->assertEquals("http://gmail.com/jo/contacts/Bob", $this->entryLink->href);
     $this->assertEquals("self", $this->entryLink->rel);
     $this->assertEquals("false", $this->entryLink->readOnly);
     $this->assertEquals(0, count($this->entryLink->extensionElements));
     $newEntryLink = new Zend_Gdata_Extension_EntryLink();
     $newEntryLink->transferFromXML($this->entryLink->saveXML());
     $this->assertEquals(0, count($newEntryLink->extensionElements));
     $newEntryLink->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newEntryLink->extensionElements));
     $this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink->href);
     $this->assertEquals("self", $newEntryLink->rel);
     $this->assertEquals("false", $newEntryLink->readOnly);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newEntryLink2 = $gdata->newEntryLink();
     $newEntryLink2->transferFromXML($newEntryLink->saveXML());
     $this->assertEquals(1, count($newEntryLink2->extensionElements));
     $this->assertEquals("http://gmail.com/jo/contacts/Bob", $newEntryLink2->href);
     $this->assertEquals("self", $newEntryLink2->rel);
     $this->assertEquals("false", $newEntryLink2->readOnly);
 }
 public function FetchContacts($credential = null)
 {
     if (!$credential) {
         $credential = $this->_credential;
     } else {
         $this->_credential = $credential;
     }
     $user = $credential['username'];
     $pass = $credential['password'];
     try {
         // perform login and set protocol version to 3.0
         $client = \Zend_Gdata_ClientLogin::getHttpClient($user, $pass, 'cp');
         $gdata = new \Zend_Gdata($client);
         $gdata->setMajorProtocolVersion(3);
         // perform query and get result feed
         $query = new \Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full');
         $query->setParam("max-results", 10000);
         $feed = $gdata->getFeed($query);
         // parse feed and extract contact information
         // into simpler objects
         $results = array();
         foreach ($feed as $entry) {
             $xml = simplexml_load_string($entry->getXML());
             $obj = $this->DatatoContact($entry, $xml);
             $results[] = $obj;
         }
     } catch (Exception $e) {
         var_dump($e->getMessage());
         return;
     }
     return $results;
 }
 public function userAction()
 {
     $gologin = Mage::getModel('sociallogin/gologin');
     $oauth_data = array('oauth_token' => $this->getRequest()->getParam('oauth_token'), 'oauth_verifier' => $this->getRequest()->getParam('oauth_verifier'));
     $requestToken = Mage::getSingleton('core/session')->getRequestToken();
     $accessToken = $gologin->getAccessToken($oauth_data, unserialize($requestToken));
     $oauthOptions = $gologin->getOptions();
     $httpClient = $accessToken->getHttpClient($oauthOptions);
     $client = new Zend_Gdata($httpClient);
     $feed = $client->getFeed('https://www.google.com/m8/feeds/contacts/default/full');
     $userInfo = $feed->getDom();
     $user = array();
     $tempName = $userInfo->getElementsByTagName("name");
     $name = $tempName->item(0)->nodeValue;
     //full name
     $arrName = explode(' ', $name, 2);
     $user['firstname'] = $arrName[0];
     $user['lastname'] = $arrName[1];
     $tempEmail = $userInfo->getElementsByTagName("email");
     $email = $tempEmail->item(0)->nodeValue;
     $user['email'] = $email;
     $customer = Mage::helper('sociallogin')->getCustomerByEmail($user['email']);
     if (!$customer || !$customer->getId()) {
         $customer = Mage::helper('sociallogin')->createCustomer($user);
     }
     Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
     die("<script type=\"text/javascript\">try{window.opener.location.reload(true);}catch(e){window.opener.location.href=\"" . Mage::getBaseUrl() . "\"} window.close();</script>");
     //$this->_redirectUrl(Mage::helper('customer')->getDashboardUrl());
 }
Example #8
0
 public function testNormalWhenShouldHaveNoExtensionElements()
 {
     $this->when->valueString = "Later";
     $this->when->endTime = "2007-06-21T21:31:56-07:00";
     $this->when->startTime = "2007-06-19T05:42:19-06:00";
     $this->assertEquals("Later", $this->when->valueString);
     $this->assertEquals("2007-06-21T21:31:56-07:00", $this->when->endTime);
     $this->assertEquals("2007-06-19T05:42:19-06:00", $this->when->startTime);
     $this->assertEquals(0, count($this->when->extensionElements));
     $newWhen = new Zend_Gdata_Extension_When();
     $newWhen->transferFromXML($this->when->saveXML());
     $this->assertEquals(0, count($newWhen->extensionElements));
     $newWhen->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newWhen->extensionElements));
     $this->assertEquals("Later", $newWhen->valueString);
     $this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen->endTime);
     $this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen->startTime);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newWhen2 = $gdata->newWhen();
     $newWhen2->transferFromXML($newWhen->saveXML());
     $this->assertEquals(1, count($newWhen2->extensionElements));
     $this->assertEquals("Later", $newWhen2->valueString);
     $this->assertEquals("2007-06-21T21:31:56-07:00", $newWhen2->endTime);
     $this->assertEquals("2007-06-19T05:42:19-06:00", $newWhen2->startTime);
 }
Example #9
0
 public function testNormalWhereShouldHaveNoExtensionElements()
 {
     $this->where->valueString = "Test Value String";
     $this->where->rel = "http://schemas.google.com/g/2005#event.alternate";
     $this->where->label = "Test Label";
     $this->assertEquals("Test Value String", $this->where->valueString);
     $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $this->where->rel);
     $this->assertEquals("Test Label", $this->where->label);
     $this->assertEquals(0, count($this->where->extensionElements));
     $newWhere = new Zend_Gdata_Extension_Where();
     $newWhere->transferFromXML($this->where->saveXML());
     $this->assertEquals(0, count($newWhere->extensionElements));
     $newWhere->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newWhere->extensionElements));
     $this->assertEquals("Test Value String", $newWhere->valueString);
     $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere->rel);
     $this->assertEquals("Test Label", $newWhere->label);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newWhere2 = $gdata->newWhere();
     $newWhere2->transferFromXML($newWhere->saveXML());
     $this->assertEquals(1, count($newWhere2->extensionElements));
     $this->assertEquals("Test Value String", $newWhere2->valueString);
     $this->assertEquals("http://schemas.google.com/g/2005#event.alternate", $newWhere2->rel);
     $this->assertEquals("Test Label", $newWhere2->label);
 }
    public function testNormalExtendedPropertyShouldHaveNoExtensionElements() {
        $this->extendedProperty->name = "http://www.example.com/schemas/2007#mycal.foo";
        $this->extendedProperty->value = "5678";
        
        $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $this->extendedProperty->name);
        $this->assertEquals("5678", $this->extendedProperty->value);
                
        $this->assertEquals(0, count($this->extendedProperty->extensionElements));
        $newExtendedProperty = new Zend_Gdata_Extension_ExtendedProperty(); 
        $newExtendedProperty->transferFromXML($this->extendedProperty->saveXML());
        $this->assertEquals(0, count($newExtendedProperty->extensionElements));
        $newExtendedProperty->extensionElements = array(
                new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
        $this->assertEquals(1, count($newExtendedProperty->extensionElements));
        $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty->name);
        $this->assertEquals("5678", $newExtendedProperty->value);

        /* try constructing using magic factory */
        $gdata = new Zend_Gdata();
        $newExtendedProperty2 = $gdata->newExtendedProperty();
        $newExtendedProperty2->transferFromXML($newExtendedProperty->saveXML());
        $this->assertEquals(1, count($newExtendedProperty2->extensionElements));
        $this->assertEquals("http://www.example.com/schemas/2007#mycal.foo", $newExtendedProperty2->name);
        $this->assertEquals("5678", $newExtendedProperty2->value);
    }
Example #11
0
    public function testNormalWhoShouldHaveNoExtensionElements() {
        $this->who->valueString = "Test Value String";
        $this->who->rel = "http://schemas.google.com/g/2005#event.speaker";
        $this->who->email = "*****@*****.**";
        
        $this->assertEquals("Test Value String", $this->who->valueString);
        $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $this->who->rel);
        $this->assertEquals("*****@*****.**", $this->who->email);
                
        $this->assertEquals(0, count($this->who->extensionElements));
        $newWho = new Zend_Gdata_Extension_Who(); 
        $newWho->transferFromXML($this->who->saveXML());
        $this->assertEquals(0, count($newWho->extensionElements));
        $newWho->extensionElements = array(
                new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
        $this->assertEquals(1, count($newWho->extensionElements));
        $this->assertEquals("Test Value String", $newWho->valueString);
        $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho->rel);
        $this->assertEquals("*****@*****.**", $newWho->email);

        /* try constructing using magic factory */
        $gdata = new Zend_Gdata();
        $newWho2 = $gdata->newWho();
        $newWho2->transferFromXML($newWho->saveXML());
        $this->assertEquals(1, count($newWho2->extensionElements));
        $this->assertEquals("Test Value String", $newWho2->valueString);
        $this->assertEquals("http://schemas.google.com/g/2005#event.speaker", $newWho2->rel);
        $this->assertEquals("*****@*****.**", $newWho2->email);
    }
Example #12
0
 public function testExceptionFormatTimestampInvalid()
 {
     $gdata = new Zend_Gdata();
     try {
         $ts = $gdata->formatTimestamp('nonsense string');
     } catch (Zend_Gdata_Exception $e) {
         $this->assertEquals('Invalid timestamp: nonsense string.', $e->getMessage());
     }
 }
 public function userAction()
 {
     $gologin = Mage::getModel('sociallogin/gologin');
     $oauth_data = array('oauth_token' => $this->getRequest()->getParam('oauth_token'), 'oauth_verifier' => $this->getRequest()->getParam('oauth_verifier'));
     $requestToken = Mage::getSingleton('core/session')->getRequestToken();
     // Fixed by Hai Ta
     try {
         $accessToken = $gologin->getAccessToken($oauth_data, unserialize($requestToken));
     } catch (Exception $e) {
         Mage::getSingleton('core/session')->addError('Login failed as you have not granted access.');
         die("<script type=\"text/javascript\">try{window.opener.location.reload(true);}catch(e){window.opener.location.href=\"" . Mage::getBaseUrl() . "\"} window.close();</script>");
     }
     // end fixed
     $oauthOptions = $gologin->getOptions();
     $httpClient = $accessToken->getHttpClient($oauthOptions);
     $client = new Zend_Gdata($httpClient);
     $feed = $client->getFeed('https://www.google.com/m8/feeds/contacts/default/full');
     $userInfo = $feed->getDom();
     $user = array();
     $tempName = $userInfo->getElementsByTagName("name");
     $name = $tempName->item(0)->nodeValue;
     //full name
     $arrName = explode(' ', $name, 2);
     $user['firstname'] = $arrName[0];
     $user['lastname'] = $arrName[1];
     $tempEmail = $userInfo->getElementsByTagName("email");
     $email = $tempEmail->item(0)->nodeValue;
     $user['email'] = $email;
     //get website_id and sote_id of each stores
     $store_id = Mage::app()->getStore()->getStoreId();
     //add
     $website_id = Mage::app()->getStore()->getWebsiteId();
     //add
     $customer = Mage::helper('sociallogin')->getCustomerByEmail($user['email'], $website_id);
     //add edition
     if (!$customer || !$customer->getId()) {
         //Login multisite
         $customer = Mage::helper('sociallogin')->createCustomerMultiWebsite($user, $website_id, $store_id);
         if (Mage::getStoreConfig('sociallogin/gologin/is_send_password_to_customer')) {
             $customer->sendPasswordReminderEmail();
         }
     }
     // fix confirmation
     if ($customer->getConfirmation()) {
         try {
             $customer->setConfirmation(null);
             $customer->save();
         } catch (Exception $e) {
         }
     }
     Mage::getSingleton('customer/session')->setCustomerAsLoggedIn($customer);
     die("<script type=\"text/javascript\">try{window.opener.location.href=\"" . $this->_loginPostRedirect() . "\";}catch(e){window.opener.location.reload(true);} window.close();</script>");
     //$this->_redirectUrl(Mage::helper('customer')->getDashboardUrl());
 }
Example #14
0
 public static function import($uri, $client = null, $className = 'Zend_Gdata_Feed')
 {
     $app = new Zend_Gdata($client);
     $requestData = $app->decodeRequest('GET', $uri);
     $response = $app->performHttpRequest($requestData['method'], $requestData['url']);
     $feedContent = $response->getBody();
     $feed = self::importString($feedContent, $className);
     if ($client != null) {
         $feed->setHttpClient($client);
     }
     return $feed;
 }
Example #15
0
 public function testGetEntryExceptionInvalidLocationType()
 {
     $gdata = new Zend_Gdata();
     try {
         // give it neither a string nor a Zend_Gdata_Query object,
         // and see if it throws an exception.
         $feed = $gdata->getEntry(new stdClass());
         $this->fail('Expecting to catch Zend_Gdata_App_InvalidArgumentException');
     } catch (Zend_Exception $e) {
         $this->assertType('Zend_Gdata_App_InvalidArgumentException', $e, 'Expecting Zend_Gdata_App_InvalidArgumentException, got ' . get_class($e));
         $this->assertEquals('You must specify the location as either a string URI or a child of Zend_Gdata_Query', $e->getMessage());
     }
 }
 public function testNormalVisibilityShouldHaveNoExtensionElements()
 {
     $this->visibility->value = "http://schemas.google.com/g/2005#event.private";
     $this->assertEquals("http://schemas.google.com/g/2005#event.private", $this->visibility->value);
     $this->assertEquals(0, count($this->visibility->extensionElements));
     $newVisibility = new Zend_Gdata_Extension_Visibility();
     $newVisibility->transferFromXML($this->visibility->saveXML());
     $this->assertEquals(0, count($newVisibility->extensionElements));
     $newVisibility->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newVisibility->extensionElements));
     $this->assertEquals("http://schemas.google.com/g/2005#event.private", $newVisibility->value);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newVisibility2 = $gdata->newVisibility();
     $newVisibility2->transferFromXML($newVisibility->saveXML());
     $this->assertEquals(1, count($newVisibility2->extensionElements));
     $this->assertEquals("http://schemas.google.com/g/2005#event.private", $newVisibility2->value);
 }
 public function testNormalAttendeeTypeShouldHaveNoExtensionElements()
 {
     $this->attendeeType->value = "http://schemas.google.com/g/2005#event.optional";
     $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $this->attendeeType->value);
     $this->assertEquals(0, count($this->attendeeType->extensionElements));
     $newAttendeeType = new Zend_Gdata_Extension_AttendeeType();
     $newAttendeeType->transferFromXML($this->attendeeType->saveXML());
     $this->assertEquals(0, count($newAttendeeType->extensionElements));
     $newAttendeeType->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newAttendeeType->extensionElements));
     $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $newAttendeeType->value);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newAttendeeType2 = $gdata->newAttendeeType();
     $newAttendeeType2->transferFromXML($newAttendeeType->saveXML());
     $this->assertEquals(1, count($newAttendeeType2->extensionElements));
     $this->assertEquals("http://schemas.google.com/g/2005#event.optional", $newAttendeeType2->value);
 }
 public function testNormalRecurrenceShouldHaveNoExtensionElements()
 {
     $this->recurrence->text = "Foo";
     $this->assertEquals("Foo", $this->recurrence->text);
     $this->assertEquals(0, count($this->recurrence->extensionElements));
     $newRecurrence = new Zend_Gdata_Extension_Recurrence();
     $newRecurrence->transferFromXML($this->recurrence->saveXML());
     $this->assertEquals(0, count($newRecurrence->extensionElements));
     $newRecurrence->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newRecurrence->extensionElements));
     $this->assertEquals("Foo", $newRecurrence->text);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newRecurrence2 = $gdata->newRecurrence();
     $newRecurrence2->transferFromXML($newRecurrence->saveXML());
     $this->assertEquals(1, count($newRecurrence2->extensionElements));
     $this->assertEquals("Foo", $newRecurrence2->text);
 }
 public function testNormalRecurrenceExceptionShouldHaveNoExtensionElements()
 {
     $this->recurrenceException->specialized = "false";
     $this->assertEquals("false", $this->recurrenceException->specialized);
     $this->assertEquals(0, count($this->recurrenceException->extensionElements));
     $newRecurrenceException = new Zend_Gdata_Extension_RecurrenceException();
     $newRecurrenceException->transferFromXML($this->recurrenceException->saveXML());
     $this->assertEquals(0, count($newRecurrenceException->extensionElements));
     $newRecurrenceException->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newRecurrenceException->extensionElements));
     $this->assertEquals("false", $newRecurrenceException->specialized);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newRecurrenceException2 = $gdata->newRecurrenceException();
     $newRecurrenceException2->transferFromXML($newRecurrenceException->saveXML());
     $this->assertEquals(1, count($newRecurrenceException2->extensionElements));
     $this->assertEquals("false", $newRecurrenceException2->specialized);
 }
 public function testNormalOpenSearchItemsPerPageShouldHaveNoExtensionElements()
 {
     $this->openSearchItemsPerPage->text = "200";
     $this->assertEquals("200", $this->openSearchItemsPerPage->text);
     $this->assertEquals(0, count($this->openSearchItemsPerPage->extensionElements));
     $newOpenSearchItemsPerPage = new Zend_Gdata_Extension_OpenSearchItemsPerPage();
     $newOpenSearchItemsPerPage->transferFromXML($this->openSearchItemsPerPage->saveXML());
     $this->assertEquals(0, count($newOpenSearchItemsPerPage->extensionElements));
     $newOpenSearchItemsPerPage->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newOpenSearchItemsPerPage->extensionElements));
     $this->assertEquals("200", $newOpenSearchItemsPerPage->text);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newOpenSearchItemsPerPage2 = $gdata->newOpenSearchItemsPerPage();
     $newOpenSearchItemsPerPage2->transferFromXML($newOpenSearchItemsPerPage->saveXML());
     $this->assertEquals(1, count($newOpenSearchItemsPerPage2->extensionElements));
     $this->assertEquals("200", $newOpenSearchItemsPerPage2->text);
 }
 public function testNormalCommentsShouldHaveNoExtensionElements()
 {
     $this->comments->rel = "http://schemas.google.com/g/2005#regular";
     $this->assertEquals("http://schemas.google.com/g/2005#regular", $this->comments->rel);
     $this->assertEquals(0, count($this->comments->extensionElements));
     $newComments = new Zend_Gdata_Extension_Comments();
     $newComments->transferFromXML($this->comments->saveXML());
     $this->assertEquals(0, count($newComments->extensionElements));
     $newComments->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(1, count($newComments->extensionElements));
     $this->assertEquals("http://schemas.google.com/g/2005#regular", $newComments->rel);
     /* try constructing using magic factory */
     $gdata = new Zend_Gdata();
     $newComments2 = $gdata->newComments();
     $newComments2->transferFromXML($newComments->saveXML());
     $this->assertEquals(1, count($newComments2->extensionElements));
     $this->assertEquals("http://schemas.google.com/g/2005#regular", $newComments2->rel);
 }
Example #22
0
 public function insertVolume($entry, $location = null)
 {
     if ($location == null) {
         $uri = self::MY_LIBRARY_FEED_URI;
     } else {
         $uri = $location;
     }
     return parent::insertEntry($entry, $uri, 'Zend_Gdata_Books_VolumeEntry');
 }
Example #23
0
 /**
  * @param string $var
  * @param string $value
  * @throws Zend_Gdata_InvalidArgumentException
  */
 protected function __set($var, $value)
 {
     switch ($var) {
         case 'updatedMin':
         case 'updatedMax':
             throw new Zend_Gdata_InvalidArgumentException("Parameter '{$var}' is not currently supported in Spreadsheets.");
             break;
     }
     parent::__set($var, $value);
 }
 /**
  * @param string $var
  * @param string $value
  */
 protected function __set($var, $value)
 {
     switch ($var) {
         case 'updatedMin':
         case 'updatedMax':
             throw Zend::exception('Zend_Gdata_Exception', "Parameter '{$var}' is not currently supported in CodeSearch.");
             break;
     }
     parent::__set($var, $value);
 }
Example #25
0
 /**
  * Class constructor
  *
  * Creates authenticated Google client. Note that this is never called directly
  * from public scope, but via the singleton function {@link GClient::getInstance()}.
  *
  * @method	GClient		GClient()	GClient($service)	creates and initializes new GClient object
  * @param	string		$service	type of service access (either St, Doc, or Raw)
  * @see		GClient::getInstance()
  * @return	GClient
  */
 public function __construct($service, $token = NULL, $captcha = NULL)
 {
     // get login credentials
     $user = get_option('gdocs_user');
     $pwd = get_option('gdocs_pwd');
     // create Zend Http Client
     $httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pwd, $service, NULL, NULL, $token, $captcha);
     $this->setProxy($httpClient);
     // create Zend Gdata client
     parent::__construct($httpClient);
 }
Example #26
0
 /**
  * Retrieve data feed object
  * 
  * @param mixed $location
  * @return Zend_Gdata_Analytics_DataFeed
  */
 public function getDataFeed($location)
 {
     if ($location == null) {
         $uri = self::ANALYTICS_FEED_URI;
     } elseif ($location instanceof Zend_Gdata_Query) {
         $uri = $location->getQueryUrl();
     } else {
         $uri = $location;
     }
     return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed');
 }
Example #27
0
 function google_Analytics_getKeywordsForProfile($profile_id, $start_date = false, $end_date = false)
 {
     $email = CI::model('content')->optionsGetByKey('google_analytics_login');
     $pass = CI::model('content')->optionsGetByKey('google_analytics_pass');
     require_once "Zend/Loader.php";
     Zend_Loader::loadClass('Zend_Gdata');
     Zend_Loader::loadClass('Zend_Gdata_Query');
     Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
     $client = Zend_Gdata_ClientLogin::getHttpClient($email, $pass, "analytics");
     $gdClient = new Zend_Gdata($client);
     if ($start_date == false) {
         $start_date = date("Y-m-d", mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")));
     }
     if ($end_date == false) {
         $end_date = date("Y-m-d", mktime(0, 0, 0, date("m") - 0, date("d"), date("Y")));
     }
     try {
         $dimensions = array("ga:region", "ga:city", "ga:latitude", "ga:longitude");
         $metrics = array("ga:visits", "ga:pageviews");
         $dimensions = array("ga:keyword");
         $metrics = array("ga:pageviews");
         //dimensions=ga:country&metrics=ga:visitors
         $reportURL = "https://www.google.com/analytics/feeds/data?ids={$profile_id}&" . "dimensions=" . @implode(",", $dimensions) . "&" . "metrics=" . @implode(",", $metrics) . "&max-results=50" . '&sort=ga:pageviews' . "&" . "start-date={$start_date}&" . "end-date={$end_date}";
         //	var_dump($reportURL);
         $results = $gdClient->getFeed($reportURL);
         $titleRow = 1;
         // To output a row of column labels
         foreach ($results as $rep) {
             if ($titleRow) {
                 foreach ($rep->extensionElements as $elem) {
                     $titles[] = $elem->extensionAttributes["name"]["value"];
                 }
                 //	echo implode ( ",", $titles ) . "\n";
                 //echo  "<hr>";
                 $titleRow = 0;
             }
             foreach ($rep->extensionElements as $elem) {
                 //var_dump($elem);
                 $the_item = $elem->extensionAttributes["value"]["value"];
                 var_dump($the_item);
                 if (strlen($the_item) > 5) {
                     print '<pre>';
                     $row[] = $the_item;
                     print '</pre>';
                 }
             }
             //echo implode ( ",", $row ) . "\n";
             //echo  "<br>";
         }
     } catch (Zend_Exception $e) {
         echo "Caught exception: " . get_class($e) . "\n";
         echo "Message: " . $e->getMessage() . "\n";
     }
 }
Example #28
0
 public function getGbaseSnippetFeed($location = null)
 {
     if ($location === null) {
         $uri = self::GBASE_SNIPPET_FEED_URI;
     } else {
         if ($location instanceof Zend_Gdata_Query) {
             $uri = $location->getQueryUrl();
         } else {
             $uri = $location;
         }
     }
     return parent::getFeed($uri, 'Zend_Gdata_Gbase_SnippetFeed');
 }
Example #29
0
 public function getDocumentListEntry($location = null)
 {
     if ($location === null) {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('Location must not be null');
     } else {
         if ($location instanceof Zend_Gdata_Query) {
             $uri = $location->getQueryUrl();
         } else {
             $uri = $location;
         }
     }
     return parent::getEntry($uri, 'Zend_Gdata_Docs_DocumentListEntry');
 }
Example #30
0
 /**
  * get Contacts list to show
  * 
  * @return array
  */
 public function getContacts()
 {
     $list = array();
     $request = $this->getRequest();
     if (!$request->getParam('oauth_token') && !$request->getParam('oauth_verifier')) {
         return $list;
     }
     $google = Mage::getSingleton('affiliateplusreferfriend/refer_gmail');
     $oauthData = array('oauth_token' => $request->getParam('oauth_token'), 'oauth_verifier' => $request->getParam('oauth_verifier'));
     $accessToken = $google->getAccessToken($oauthData, unserialize($google->getGmailRequestToken()));
     $oauthOptions = $google->getOptions();
     $httpClient = $accessToken->getHttpClient($oauthOptions);
     $gdata = new Zend_Gdata($httpClient);
     $query = new Zend_Gdata_Query('https://www.google.com/m8/feeds/contacts/default/full');
     $query->setMaxResults(10000);
     $feed = array();
     try {
         $feed = $gdata->getFeed($query);
     } catch (Exception $e) {
     }
     foreach ($feed as $entry) {
         $_contact = array();
         $xml = simplexml_load_string($entry->getXML());
         $_contact['name'] = $entry->title;
         foreach ($xml->email as $e) {
             $email = '';
             if (isset($e['address'])) {
                 $email = (string) $e['address'];
             }
             if ($email) {
                 $_contact['email'] = $email;
                 $list[] = $_contact;
             }
         }
     }
     return $list;
 }