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.


Posted

in

by

Tags: