public function get($uri, $extraHeaders = array()) { try { return parent::get($uri, $extraHeaders); } catch (Zend_Gdata_App_HttpException $e) { self::throwServiceExceptionIfDetected($e); } }
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); } } }
// People without a photo will have this link but no "etag" attribute if ( empty( $link->extensionAttributes['http://schemas.google.com/g/2005:etag'] ) ) continue 2; $image_url = $link->href; } if ( !$image_url ) continue; // Find the photo update URL $update_url = false; foreach ( $response->link as $link ) { if ( 'http://schemas.google.com/contacts/2008/rel#photo' !== $link->rel ) continue; $update_url = $link->href; } if ( !$update_url ) continue; // Fetch the source image $image_request = $source_gdata->get( $image_url ); $image = $image_request->getBody(); // Save the image to the destination contact $dest_gdata->put( $image, $update_url, null, 'image/*', array( 'If-Match' => '*' ) ); message( ' Created ' . $entry->title ); } message( "\nAll done!" );
/** * GET a uri using client object. * This method overrides the default behavior of Zend_Gdata_App, * providing support for Zend_Gdata_Gapps_ServiceException. * * @param string $uri * @throws Zend_Gdata_App_HttpException * @throws Zend_Gdata_Gapps_ServiceException * @return Zend_Http_Response */ public function get($uri) { try { return parent::get($uri); } catch (Zend_Gdata_App_HttpException $e) { self::throwServiceExceptionIfDetected($e); } }