public function testSetAndGetMaxResults() { $query = new Zend_Gdata_Query(); $query->setMaxResults('300'); $this->assertEquals('300', $query->getMaxResults()); $this->assertTrue(strpos($query->getQueryUrl(), 'max-results=300') !== false); }
public function testSetAndGetMaxResults() { $query = new Zend_Gdata_Query(); $query->setMaxResults('300'); $this->assertEquals('300', $query->getMaxResults()); $this->assertContains('max-results=300', $query->getQueryUrl()); }
/** * 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; }
/** * Retrieve user's uploaded videos. * * @param $maxResults int * Maximum number of YoutubeVideo to return. * @return array(YoutubeVideo) Videos retrieved. */ public function getVideos($maxResults) { try { set_include_path(get_include_path() . PATH_SEPARATOR . dirname(WSW_Main::$plugin_dir) . '/lib/Youtube'); if (!class_exists('Zend_Loader')) { require_once 'Zend/Loader.php'; } Zend_Loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_YouTube'); // If the keyword is compoused, divide each word $key_phrase = $this->keyword; $key_phrase_arr = explode(' ', $key_phrase); $query_url = Zend_Gdata_YouTube::VIDEO_URI . "/-/"; foreach ($key_phrase_arr as $key_phrase_item) { if (trim($key_phrase_item) != '') { $query_url .= trim($key_phrase_item) . '/'; } } //$query_url .= '?v=2'; $query = new Zend_Gdata_Query($query_url); $query->setMaxResults($maxResults); $query->setParam('orderby', 'viewCount'); $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); $videoFeed = $yt->getFeed($query, 'Zend_Gdata_YouTube_VideoFeed'); // TODO See how this initialization must be done, I mean if is really neccesary $keyVideos = array(); foreach ($videoFeed as $videoEntry) { $keyVideos[] = new WSW_YoutubeVideo($videoEntry); } return $keyVideos; } catch (Exception $e) { // Store to log $msg_to_log = 'Error while getVideos from Youtube, Url: ' . $query_url . ', Exception Msg: ' . $e->getMessage(); return array(); } }
/** * * @param string $object * @param int $offset_start * @param int $quantity * @return string */ protected function get_user_object_list_feed($object, $offset_start, $quantity) { $feed = null; switch ($object) { case self::ELEMENT_TYPE_VIDEO: $uri = Zend_Gdata_YouTube::USER_URI . '/default/' . Zend_Gdata_YouTube::UPLOADS_URI_SUFFIX; $query = new Zend_Gdata_Query($uri); if ($quantity !== 0) { $query->setMaxResults($quantity); } $query->setStartIndex($offset_start); $feed = $this->_api->getUserUploads(null, $query); break; case self::CONTAINER_TYPE_PLAYLIST: $uri = Zend_Gdata_YouTube::USER_URI . '/default/playlists'; $query = new Zend_Gdata_Query($uri); if ($quantity !== 0) { $query->setMaxResults($quantity); } $query->setStartIndex($offset_start); $feed = $this->_api->getPlaylistListFeed(null, $query); break; default: throw new Bridge_Exception_ObjectUnknown('Unknown object ' . $object); break; } return $feed; }
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); } } }
/** * * @param $maxResults int * Maximum number of YoutubeVideo to return. * @return array(YoutubeVideo) Videos retrieved. */ public function getRelatedVideos($maxResults) { try { if (!class_exists('Zend_Loader')) { require_once WPPostsRateKeys::$plugin_dir . 'classes/YoutubeWordpress/Zend/Loader.php'; } Zend_Loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_YouTube'); $query = new Zend_Gdata_Query(Zend_Gdata_YouTube::VIDEO_URI . "/{$this->videoEntry->getVideoId()}/" . Zend_Gdata_YouTube::RELATED_URI_SUFFIX); $query->setMaxResults($maxResults); $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); $relatedVideosFeed = $yt->getFeed($query, 'Zend_Gdata_YouTube_VideoFeed'); // TODO See how this initialization must be done, I mean if is really neccesary. $relatedVideos = array(); foreach ($relatedVideosFeed as $relatedVideoEntry) { $relatedVideos[] = new YoutubeVideo($relatedVideoEntry); } return $relatedVideos; } catch (Exception $e) { // Store to log $msg_to_log = 'Error while getRelatedVideos from Youtube' . ', Exception Msg: ' . $e->getMessage(); // Add log WPPostsRateKeys_Logs::add_error('362', $msg_to_log); return array(); } }
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)); }
/** * 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); } }