Ejemplo n.º 1
0
 public function put($data, $uri = null, $remainingRedirects = null, $contentType = null, $extraHeaders = null)
 {
     try {
         return parent::put($data, $uri, $remainingRedirects, $contentType, $extraHeaders);
     } catch (Zend_Gdata_App_HttpException $e) {
         self::throwServiceExceptionIfDetected($e);
     }
 }
Ejemplo n.º 2
0
		// 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!" );
 /**
  * Updates user's contact in Gmail while exporting from Ofuz to Gmail.
  * @param array, array : $row (existing contact in Gmail), $entry (contact details to be updated)
  * @return void : sets the status
  */
 function updateOfuzContactInGmail($row, $entry)
 {
     global $_SESSION, $_GET;
     $client = $this->client;
     $gdata = new Zend_Gdata($client);
     $xml = "<?xml version='1.0' encoding='UTF-8' ?>";
     $xml .= "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>";
     $xml .= "<id>" . $row['id'] . "</id>";
     //$xml .= "<updated>".$this->updated."</updated>";
     $xml .= "<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact' />";
     $xml .= "<title type='text'>" . htmlentities($entry['name'], ENT_QUOTES) . "</title>";
     // $xml .= "<content type='text'>".$this->content."</content>";
     $xml .= "<link rel='self' type='application/atom+xml' href='" . $row['link_self'] . "' />";
     $xml .= "<link rel='edit' type='application/atom+xml' href='" . $row['link_edit'] . "' />";
     if ($entry['email_Home']) {
         $xml .= '<gd:email rel="http://schemas.google.com/g/2005#home" address="' . $entry['email_Home'] . '"></gd:email>';
     }
     if ($entry['email_Work']) {
         $xml .= '<gd:email rel="http://schemas.google.com/g/2005#work" address="' . $entry['email_Work'] . '"></gd:email>';
     }
     if ($entry['email_Other']) {
         $xml .= '<gd:email rel="http://schemas.google.com/g/2005#other" address="' . $entry['email_Other'] . '"></gd:email>';
     }
     if ($entry['phone_Mobile'] != "") {
         $xml .= "<gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile' >" . $entry['phone_Mobile'] . "</gd:phoneNumber>";
     }
     if ($entry['phone_Home'] != "") {
         $xml .= "<gd:phoneNumber rel='http://schemas.google.com/g/2005#home' >" . $entry['phone_Home'] . "</gd:phoneNumber>";
     }
     if ($entry['phone_Work'] != "") {
         $xml .= "<gd:phoneNumber rel='http://schemas.google.com/g/2005#work' >" . $entry['phone_Work'] . "</gd:phoneNumber>";
     }
     if ($entry['addr_Work']) {
         $xml .= "<gd:postalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>" . htmlentities($entry['addr_Work'], ENT_QUOTES) . "</gd:postalAddress>";
     }
     if ($entry['addr_Home']) {
         $xml .= "<gd:postalAddress rel='http://schemas.google.com/g/2005#home' >" . htmlentities($entry['addr_Home'], ENT_QUOTES) . "</gd:postalAddress>";
     }
     if ($entry['addr_Other']) {
         $xml .= "<gd:postalAddress rel='http://schemas.google.com/g/2005#other' >" . htmlentities($entry['addr_Other'], ENT_QUOTES) . "</gd:postalAddress>";
     }
     if ($entry['company']) {
         $xml .= "<gd:organization rel='http://schemas.google.com/g/2005#other'>";
         $xml .= "<gd:orgName>" . htmlentities($entry['company'], ENT_QUOTES) . "</gd:orgName>";
         if ($entry['position']) {
             $xml .= "<gd:orgTitle>" . htmlentities($entry['position'], ENT_QUOTES) . "</gd:orgTitle>";
         }
         $xml .= "</gd:organization>";
     }
     $xml .= "</entry>";
     try {
         $retVal = $gdata->put($xml, $row['link_edit']);
         if ($retVal) {
             return true;
         }
     } catch (Exception $e) {
         $status_code = $gdata->getHttpClient()->getLastResponse()->getStatus();
         $this->status_code_desc = $this->getStatusDescription($status_code);
     }
 }