Spreadsheet Code

I’ve noticed a serious uptick in visitors to this blog lately, more than likely fellow coders looking for a solution to this Zend/Google issue. For the heck of it, I’m going to post a single broken php module here. This code returned a list of worksheets for a single spreadsheet. It used to work, and now it don’t:

header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
ini_set('default_charset', 'utf-8');
require_once 'Zend/Loader.php';
$username = ...
$password = ...
$sheetkey = ...
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
Zend_Loader::loadClass('Zend_Gdata_Docs');
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service);
$spreadSheetService = new Zend_Gdata_Spreadsheets($client);
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($sheetkey);
$feed = $spreadSheetService->getWorksheetFeed($query);
...

$feed used to contain a nice little array of worksheets, which I return as a json object, but now the code triggers a jQuery response of:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Feedback is most welcome, please comment here or email me at tetonpost at gmail.

Update: Ok, I’ve managed to construct some code that bounces around the Google servers to create this:

Refresh token: 1/eFTQyK2cuGrI_rfVxeBIgMr_a0aIZHdfYzXB0vCaNyE...
Access token: ya29.gwEfRnS1IrruwXi_0mIL3P9IwLoH_pIPMZbU6wXfY...

Now I just need use these tokens, which only last for milliseconds as I understand, to access the Google API. Do I use Zend at that point? What a bunch of bullshit…

3 comments

  1. They just had a Google Coders convention in SF last week. Maybe you are attracting some of them. I’ve just spent two days digging and pulling dandelions in our front and backyard and I’m still not done. Probably have 3 or 4 days more of digging. You would think with our drought we wouldn’t have all of those pesky plants. Hey, hope you can make it to California this year.

  2. Try the Google Play store to get tools for developing apps in Google. There was an article in the Chronicle today (Sunday) about “Getting developers to make apps for Android and iOS.”

Leave a comment