Since Google sample code only describes how to do half a job, here's something that hopefully might end up in a search result quicker than when I was looking for it!
I wanted to do the seemingly simple task of displaying a list of 10 recent blog entries with hyperlinks going to the entries. I ended up looking at Google Calendar sample code to figure out how to get the relative link. Maybe smart people who do this all the time are supposed to just know the syntax, but I didn't.
<?php>
$gdClient = new Zend_Gdata();
$blogID = 'your blog id here';
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/' . $blogID . '/posts/default/');
$query->setParam('max-results', 10);
$feed = $gdClient->getFeed($query);
$i = 0;
foreach($feed->entries as $entry)
{
$posturl = $entry->getLink('alternate')->getHref();
echo '<a href="$posturl">' . $entry->title->text . '</a>';
$i++;
}
?>
Here is my "missing link" - $entry->getLink('alternate')->getHref();
Also, btw - don't forget to load the necessary classes:
<?php>
require_once 'zendloader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_Feed');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
?>
Displaying a list of post titles AND their links!
0
Subscribe to:
Post Comments (Atom)