Hi Michael,
Yes, this is possible -- though media support hasn't really been added into the Base component of the PHP client library. Until that exists, you'll need to parse some links yourself and build what's called a MediaFileSource object yourself.
Code is below. I've also added an issue in the issue tracker here:
http://framework.zend.com/issues/browse/ZF-2440Here's the code:
?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gbase');
// Parameters for ClientAuth authentication
$service = Zend_Gdata_Gbase::AUTH_SERVICE_NAME;
$user = 'e-mail address';
$pass = 'password';
// Create an authenticated HTTP client
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
// Create an instance of the Base service
$service = new Zend_Gdata_Gbase($client);
$feed = $service->getGbaseItemFeed();
// loop through all of my items and add a png image attachment
foreach ($feed as $entry) {
echo $entry->title . "\n";
$extEls = $entry->getExtensionElements();
$mediaLinkHref = null;
foreach ($extEls as $extEl) {
if ($extEl->rootNamespaceURI == '
http://schemas.google.com/g/2005'
&& $extEl->rootElement == 'feedLink') {
// this is a feedLink element
$extAtts = $extEl->getExtensionAttributes();
if ($extAtts['rel']['value'] == 'media') {
$mediaLinkHref = $extAtts['href']['value'];
}
}
}
if ($mediaLinkHref != null) {
echo "we have a media link href\n";
echo "let's upload an image\n";
$mediaFileSource = $service->newMediaFileSource('070528-020016.png');
$mediaFileSource->setContentType('image/png');
try {
$service->post($mediaFileSource, $mediaLinkHref);
} catch (Zend_Gdata_App_Exception $e) {
var_dump($e);
}
}
}