public function getHealthProfileFeed($query = null) { if ($this->_httpClient->getClientLoginToken() !== null && $this->getProfileID() == null) { require_once 'Zend/Gdata/App/AuthException.php'; throw new Zend_Gdata_App_AuthException('Profile ID must not be null. Did you call setProfileID()?'); } if ($query instanceof Zend_Gdata_Query) { $uri = $query->getQueryUrl(); } else { if ($this->_httpClient->getClientLoginToken() !== null && $query == null) { $uri = self::CLIENTLOGIN_PROFILE_FEED_URI . '/' . $this->getProfileID(); } else { if ($query === null) { $uri = self::AUTHSUB_PROFILE_FEED_URI; } else { $uri = $query; } } } // use correct feed for /h9 or /health if ($this->_useH9Sandbox) { $uri = preg_replace('/\\/health\\//', '/h9/', $uri); } return parent::getFeed($uri, 'Zend_Gdata_Health_ProfileFeed'); }
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 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 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()); }
/** * Retrieve feed object * * @return Zend_Gdata_Calendar_ListFeed */ public function getContactListFeed() { $query = new Zend_Gdata_Query(self::CONTACT_FEED_URI); $query->maxResults = $this->maxResults; $query->startIndex = $this->startIndex; return parent::getFeed($query, 'Zend_Gdata_Contacts_ListFeed'); }
/** * Retreive feed object * * @return Zend_Feed */ public function getCodeSearchFeed($uri = null) { if ($uri == null) { $uri = self::CODESEARCH_FEED_URI; } $uri .= $this->getQueryString(); return parent::getFeed($uri); }
public function getUserAnnotationFeed($location = null) { if ($location == null) { $uri = self::MY_ANNOTATION_FEED_URI; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed'); }
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()); }
/** * 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'); }
public function getContactListFeed($location = null) { if ($location == null) { $uri = self::CONTACTS_FEED_URI . '/default/full'; } else { if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } } return parent::getFeed($uri, 'Zend_Gdata_Contacts_ListFeed'); }
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'); }
public function getDocumentListFeed($location = null) { if ($location === null) { $uri = self::DOCUMENTS_LIST_FEED_URI; } else { if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } } return parent::getFeed($uri, 'Zend_Gdata_Docs_DocumentListFeed'); }
public function testGetFeedExceptionInvalidLocationType() { $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->getFeed(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 post($param) { $asin = $xml->Items->Item->ASIN; $title = $param['title']; $content = $param['content']; $keyword = $param['keyword']; /* Post to Blogger */ $client = Zend_Gdata_ClientLogin::getHttpClient($param['email'], $param['password'], 'blogger', null, Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null, Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE'); $gdClient = new Zend_Gdata($client); $query = new Zend_Gdata_Query('http://www.blogger.com/feeds/default/blogs'); $feed = $gdClient->getFeed($query); $uri = 'http://www.blogger.com/feeds/' . $param['blog_id'] . '/posts/default'; $entry = $gdClient->newEntry(); $entry->title = $gdClient->newTitle($title); $entry->content = $gdClient->newContent($content); $entry->content->setType('text'); $createdPost = $gdClient->insertEntry($entry, $uri); $idText = split('-', $createdPost->id->text); $url = $createdPost->link[4]->href; $newPostID = $idText[2]; return $newPostID; }
/** * 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; }
/** * Retreive feed object * * @return Zend_Feed */ public function getCalendarListFeed() { $uri = self::CALENDAR_FEED_URI; if (isset($this->_params['_user'])) { $uri .= '/' . $this->_params['_user']; } else { $uri .= '/default'; } return parent::getFeed($uri); }
public function testDisableXMLToObjectMappingReturnsStringForEntry() { $gdata = new Zend_Gdata(); $gdata->useObjectMapping(false); $xmlString = $gdata->getFeed('http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8'); $this->assertEquals('string', gettype($xmlString)); }
/** * Retrieve data feed object * * @param string|Zend_Uri_Uri $uri * @return Zend_Gdata_Analytics_DataFeed */ public function getDataFeed($uri = self::ANALYTICS_FEED_URI) { if ($uri instanceof Query) { $uri = $uri->getQueryUrl(); } return parent::getFeed($uri, 'Zend_Gdata_Analytics_DataFeed'); }
$query_result = mysql_query($query); $result = mysql_fetch_array($query_result); $gpass = $result['gpass']; $pass = $gpass; } else { return; } 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->maxResults = 1000; $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 = new stdClass(); $obj->name = (string) $entry->title; if (strlen(strstr($obj->name, $search)) > 0) { foreach ($xml->phoneNumber as $p) { $obj->phoneNumber[] = (string) $p; } $results[] = $obj; } else { continue; }
/** * Retreive PhotoFeed object containing comments and tags associated * with a given photo. * * @param mixed $location (optional) The location for the feed, as a URL * or Query. If not specified, the community search feed will * be returned instead. * @return Zend_Gdata_Photos_PhotoFeed * @throws Zend_Gdata_App_Exception * @throws Zend_Gdata_App_HttpException */ public function getPhotoFeed($location = null) { if ($location === null) { $uri = self::PICASA_BASE_FEED_URI . '/' . self::DEFAULT_PROJECTION . '/' . self::COMMUNITY_SEARCH_PATH; } else { if ($location instanceof Zend_Gdata_Photos_UserQuery) { $location->setType('feed'); $uri = $location->getQueryUrl(); } else { if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } } } return parent::getFeed($uri, 'Zend_Gdata_Photos_PhotoFeed'); }
// Perform source login $source_client = Zend_Gdata_ClientLogin::getHttpClient( $source_user, $source_pass, 'cp' ); $source_gdata = new Zend_Gdata( $source_client ); $source_gdata->setMajorProtocolVersion( 3 ); // Perform destination login $dest_client = Zend_Gdata_ClientLogin::getHttpClient( $dest_user, $dest_pass, 'cp' ); $dest_gdata = new Zend_Gdata( $dest_client ); $dest_gdata->setMajorProtocolVersion( 3 ); // Fetch all destination contacts message( 'Fetching all "My Contacts" from destination account...' ); $dest_query = new Zend_Gdata_Query( 'http://www.google.com/m8/feeds/contacts/default/full' ); $dest_query->maxResults = 99999; $dest_query->setParam( 'group', 'http://www.google.com/m8/feeds/groups/' . urlencode($dest_user) . '/base/6' ); // "My Contacts" only $dest_feed = $dest_gdata->getFeed( $dest_query ); message( $dest_feed->totalResults . ' contacts found.' ); // Clear out all existing contacts if ( (string) $dest_feed->totalResults > 0 ) { message( 'Clearing all "My Contacts" from destination account...' ); foreach ( $dest_feed as $entry ) { if ( !$editlink = $entry->getEditLink() ) continue; $entry = $dest_gdata->getEntry( $editlink->getHref() ); $dest_gdata->delete( $entry ); message( ' Deleted ' . $entry->title ); }
function GoogleContactPhoto($GoogleContactsClient, $ContactEmail) { $lnkPhotoGet = 'http://google.com/m8/feeds/photos/media/'; $gdata = new Zend_Gdata($GoogleContactsClient); $query = new Zend_Gdata_Query($lnkPhotoGet . $ContactEmail . '/c9012de'); $query->setMaxResults(10000); $feed = $gdata->retrieveAllEntriesForFeed($gdata->getFeed($query)); }
/** * Gets a list feed. * @param string $location A ListQuery or a URI specifying the feed location. * @return ListFeed */ public function getListFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_ListFeed'); }
/** * @return string blogname */ public function getBloggerListFeed() { $uri = self::BLOGGER_LIST_URI; return parent::getFeed($uri); }
/** * Gets a list feed. * * @param mixed $location A ListQuery, WorksheetEntry or string URI specifying the feed location. * @return ListFeed */ public function getListFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) { $uri = $location->getQueryUrl(); } else { if ($location instanceof Zend_Gdata_Spreadsheets_WorksheetEntry) { $uri = $location->getLink(self::LIST_FEED_LINK_URI)->href; } else { $uri = $location; } } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_ListFeed'); }
function GoogleContactPhoto($GoogleContactsClient) { $data = array(); $lnkPhotoGet = 'http://google.com/m8/feeds/contacts/jayanth.bagare%40gmail.com/full'; $gdata = new Zend_Gdata($GoogleContactsClient); $query = new Zend_Gdata_Query($lnkPhotoGet); $query->setMaxResults(10000); $feed = $gdata->getFeed($query); foreach ($feed as $entry) { array_push($data, $entry); } $contacts[] = $data; foreach ($contacts as $entry) { if ($entry['link_photo']) { Zend_Loader::loadClass('Zend_Http_Response'); $http_response = $gdata->get($entry['link_photo']); $rawImage = $http_response->getBody(); $headers = $http_response->getHeaders(); $contentType = $headers["Content-type"]; header("Content-type: " . $contentType); var_dump($rawImage); } } }
/** * Retrieve feed object * * @return Zend_Gdata_Calendar_ListFeed */ public function getCalendarListFeed() { $uri = self::CALENDAR_FEED_URI . '/default'; return parent::getFeed($uri, 'Zend_Gdata_Calendar_ListFeed'); }
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"; } }
/** * Retreive EmailListRecipientFeed object containing multiple * EmailListRecipientEntry objects. * * @param mixed $location The location for the feed, as a URL or Query. * @return Zend_Gdata_Gapps_EmailListRecipientFeed * @throws Zend_Gdata_App_Exception * @throws Zend_Gdata_App_HttpException * @throws Zend_Gdata_Gapps_ServiceException */ public function getEmailListRecipientFeed($location) { 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::getFeed($uri, 'Zend_Gdata_Gapps_EmailListRecipientFeed'); }
/** * @param string $value */ public function getItemTypeAttributesFeed($itemType) { $uri = self::BASE_METADATA_ATTRIBUTES_URI; $this->query = $itemType; return parent::getFeed($uri); }