Zend Framework, Gdata, Blogger and AuthSub

So I am working on adding the ability to post to Blogger on the current project I am working on. It has been a tricky road getting there, so I thought I would “document” my learning trail.

  1. First place to start out is this getting started page for posting to Blogger using Gdata.
  2. There is an extension to the Zend Framework that makes it easy to work with Gdata API in PHP. You can either use entire Zend Framework, or just the Gdata Client.
  3. There is an explanation for installing and configuring the Gdata Client and the Zend Framework, here.
  4. I am installing this on MAMP, (a self-contained PHP, MySQL package) and was having trouble getting the php include_path to work correctly. I tried this method out and it works fine. Basically you create a symbolic link to the /library/Zend folder, call the link Zend and place it next to the php folder at: /Applications/MAMP/bin/php5/lib. You then have to change the php.ini file located at /Apps/MAMP/conf/php5 and change the include_path to include_path = “.:/Applications/MAMP/bin/php5/lib”.
  5. The build for just the Gdata Client instead of the entire framework is missing a file. Just comment out line 50 of client.php. Supposedly future builds will fix this problem.
  6. The sample code for doing AuthSub uses a function called getCurrentUrl(); I couldn’t find this function anywhere so I just hardcoded it.
  7. The sample code gives an include block:
    require_once 'Zend/Loader.php';
    Zend_Loader::loadClass('Zend_Gdata');
    Zend_Loader::loadClass('Zend_Gdata_Query');
    

    Zend_Loader::loadClass(‘Zend_Gdata_ClientLogin’);
    This is for doing a client login instead of AuthSub, which is used for connecting to Google via another website. In order to do this you need to include the class for this. Do this by adding this line:
    Zend_Loader::loadClass(‘Zend_Gdata_AuthSub’);   

  8. Another error in the AuthSub sample code. Here is the block:
    function getAuthSubUrl()
    {
    $next = getCurrentUrl();
    $scope = 'http://www.google.com/blogger/feeds/';
    $secure = false;
    $session = true;
    return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session);
    }$authSubUrl = getAuthSubUrl();
    

    echo ‘<a href=\”$authSubUrl\”>login to your Google account</a>’;
    The scope is set incorrectly. It should not goto google.com. In the text below and the sample URL, they have it correct. It should be:
    $scope = ‘http://www.blogger.com/feeds/’;

  9. Turns out that they forgot to load another class needed for the blogger. Add this line following the other Zend_Loaders. You need it in order to view all of the Blogs a user has.
    Zend_Loader :: loadClass(‘Zend_Gdata_Feed’);

Yea… so not what I would call out of the box functionality. I will add more to this as I work with the API and find other fun things to work around.

Google Gadgets

I am working on a new top secret project and part of it involves a Google Gadget. I just spent 2 hours trying to work out why links get stuck in an iframe instead of the parent page.

Here is the answer that took a while to find:

External Links

Gadgets that wish to direct the user to a third-party site should do so in a new window. All links should set target="_blank" in any href tags so that external links do not open inside of the gadget’s iframe.

Gov 2.0 Expo & Summit

I went to the Gov 2.0 Summit today. It was a great experience. It was really great to see all these people coming to together for Gov. I am excited for the Summit tomorrow. It should bring together some real heavy hitters.

They also announced the winners of Apps for America. Data Masher got the top slot, Gov Pulse got second, and This we Know got third. A great showing from everyone. Apparently the votes were very close.

Apps for America 2 – winners

They have announced the winners for Apps for America 2. I submitted two apps which I had clobbered together. Unfortunately I didn’t make it as a finalist or win the visualization prize. The Apps that did win were written by teams of people who actually know what they are doing… I am just happy I got something working. This was my first experience using PHP to pull web data from APIs and I learned a lot. I am still hoping I win one of the 10 honorable mentions!

Submitted two apps

I submitted two apps to the Apps for America 2 contest. They provide an interface to the USASpending.gov website, taking you current location and providing information on the federal money being spent locally.

Local Spending – Provides you information on the federal money being spent in your current zip code, district or state.

Local Recovery – Provides the amount of federal recovery money that has been spent in your current zip code, district or state.

While I hope I win something, I had a lot of fun just working on the apps. I got to learn a lot about using PHP to pull in information from an API and restructure it. Good times!