Beispiel #1
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());
     }
 }
Beispiel #2
0
 public function getVolumeEntry($volumeId = null, $location = null)
 {
     if ($volumeId !== null) {
         $uri = self::VOLUME_FEED_URI . "/" . $volumeId;
     } else {
         if ($location instanceof Zend_Gdata_Query) {
             $uri = $location->getQueryUrl();
         } else {
             $uri = $location;
         }
     }
     return parent::getEntry($uri, 'Zend_Gdata_Books_VolumeEntry');
 }
Beispiel #3
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');
 }
 /**
  * Retreive a single CommentEntry object.
  *
  * @param mixed $location The location for the feed, as a URL or Query.
  * @return Zend_Gdata_Photos_CommentEntry
  * @throws Zend_Gdata_App_Exception
  * @throws Zend_Gdata_App_HttpException
  */
 public function getCommentEntry($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_Photos_UserQuery) {
             $location->setType('entry');
             $uri = $location->getQueryUrl();
         } else {
             if ($location instanceof Zend_Gdata_Query) {
                 $uri = $location->getQueryUrl();
             } else {
                 $uri = $location;
             }
         }
     }
     return parent::getEntry($uri, 'Zend_Gdata_Photos_CommentEntry');
 }
Beispiel #5
0
 /**
  * Gets a list entry.
  *
  * @param string $location A ListQuery or a URI specifying the entry location.
  * @return ListEntry
  */
 public function getListEntry($location)
 {
     if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) {
         $uri = $location->getQueryUrl();
     } else {
         $uri = $location;
     }
     return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_ListEntry');
 }
Beispiel #6
0
 /**
  * Retrieve a profile entry object
  *
  * @param mixed $query The query for the feed, as a URL or Query
  * @return Zend_Gdata_Health_ProfileEntry
  */
 public function getHealthProfileEntry($query = null)
 {
     if ($query === null) {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('Query must not be null');
     } else {
         if ($query instanceof Zend_Gdata_Query) {
             $uri = $query->getQueryUrl();
         } else {
             $uri = $query;
         }
     }
     return parent::getEntry($uri, 'Zend_Gdata_Health_ProfileEntry');
 }
Beispiel #7
0
 /**
  * Retrieve a single feed object by id
  *
  * @param string $entryID
  * @return string|Zend_Gdata_App_Feed
  */
 public function getContactEntry($entryID)
 {
     return parent::getEntry($entryID, 'Zend_Gdata_Contacts_ListEntry');
 }
 public function testDisableAndReEnableXMLToObjectMappingReturnsObject()
 {
     $gdata = new Zend_Gdata();
     $gdata->useObjectMapping(false);
     $xmlString = $gdata->getEntry('http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8');
     $this->assertEquals('string', gettype($xmlString));
     $gdata->useObjectMapping(true);
     $entry = $gdata->getEntry('http://gdata.youtube.com/feeds/api/videos/O4SWAfisH-8');
     $this->assertTrue($entry instanceof Zend_Gdata_Entry);
 }
Beispiel #9
0
 /**
  * Retreive a single EmailListRecipientEntry object.
  *
  * @param mixed $location The location for the feed, as a URL or Query.
  * @return Zend_Gdata_Gapps_EmailListRecipientEntry
  * @throws Zend_Gdata_App_Exception
  * @throws Zend_Gdata_App_HttpException
  * @throws Zend_Gdata_Gapps_ServiceException
  */
 public function getEmailListRecipientEntry($location)
 {
     if ($location === null) {
         require_once LIB_DIR . '/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_Gapps_EmailListRecipientEntry');
 }
Beispiel #10
0
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 );
	}
	message( 'Existing "My Contacts" cleared from destination account.' );
}

// Fetch all source contacts
message( 'Fetching all "My Contacts" from source account...' );
$source_query = new Zend_Gdata_Query( 'http://www.google.com/m8/feeds/contacts/default/full' );
$source_query->maxResults = 99999;
$source_query->setParam( 'group', 'http://www.google.com/m8/feeds/groups/' . urlencode($source_user) . '/base/6' ); // "My Contacts" only
$source_feed = $source_gdata->getFeed( $source_query );
message( $source_feed->totalResults . ' contacts found.' );
Beispiel #11
0
 /**
  * Retreive entry object
  *
  * @param mixed $location The location for the feed, as a URL or Query
  * @return Zend_Gdata_Gbase_ItemEntry
  */
 public function getGbaseItemEntry($location = null)
 {
     if ($location === null) {
         require_once PHP_LIBRARY_PATH . '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_Gbase_ItemEntry');
 }
 /**
  * retrieves single contact from Gmail associated with a User.
  *
  * @param string : contact self link
  */
 function retreiveSingleContact($link_self)
 {
     global $_SESSION, $_GET;
     $client = $this->client;
     //This is to fetch single contact which is to be updated.
     // Create a Gdata object using the authenticated Http Client
     $gdata = new Zend_Gdata($client);
     try {
         $entry = $gdata->getEntry($link_self);
         $data = $this->pushContactIntoArray($entry);
         $contacts[] = $data;
         return $contacts;
     } catch (Exception $e) {
         $status_code = $gdata->getHttpClient()->getLastResponse()->getStatus();
         $this->status_code_desc = $this->getStatusDescription($status_code);
     }
 }