zend framework - Error Saving Form Data to Google Spreadsheets Using PHP and the Google Docs API -
i need post results html form/survey google docs spreadsheet. right i'm trying simplest scenario api, writing simple row spreadsheet, although maintain getting error. (i'm not great php, please bear me!)
code:
<?php set_include_path(get_include_path() . path_separator . "$_server[document_root]/zendgdata-1.12.1/library"); require_once 'zend/loader.php'; zend_loader::loadclass('zend_gdata'); zend_loader::loadclass('zend_gdata_query'); zend_loader::loadclass('zend_gdata_spreadsheets'); zend_loader::loadclass('zend_gdata_clientlogin'); ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> </head> <body> <?php error_reporting(e_all); ini_set("display_errors", 1); $user = "######"; $pass = "######"; $service = "xapi"; $client = zend_gdata_clientlogin::gethttpclient($user, $pass, $service, null, zend_gdata_clientlogin::default_source, null, null, zend_gdata_clientlogin::clientlogin_uri, 'google'); $spreadsheetservice = new zend_gdata_spreadsheets($client); $feed = $spreadsheetservice->getspreadsheetfeed(); foreach ($feed $entry) { echo 'title: ' . $entry->title . ' - '; echo 'id: ' . $entry->id . '<br />'; } $rowdata = array('wood' => 'oak'); $spreadsheetkey = '######'; $worksheetid = 'od6'; try{ $insertedlistentry = $spreadsheetservice->insertrow($rowdata, $spreadsheetkey, $worksheetid); } catch(zend_gdata_app_httpexception $exception) { echo "error: " . $exception->getresponse()->getrawbody(); } ?> </body> </html>
error:
> fatal error: uncaught exception 'zend_gdata_app_httpexception' > message 'expected response code 200, got 401 <html> <head> > <title>token invalid</title> </head> <body bgcolor="#ffffff" > text="#000000"> <h1>token invalid</h1> <h2>error 401</h2> </body> > </html> ' in > c:\xampp\htdocs\zendgdata-1.12.1\library\zend\gdata\app.php:714 stack > trace: #0 > c:\xampp\htdocs\zendgdata-1.12.1\library\zend\gdata.php(219): > zend_gdata_app->performhttprequest('get', 'https://spreads...', array, > null, null, null) #1 > c:\xampp\htdocs\zendgdata-1.12.1\library\zend\gdata\app.php(880): > zend_gdata->performhttprequest('get', 'https://spreads...', array) #2 > c:\xampp\htdocs\zendgdata-1.12.1\library\zend\gdata\app.php(768): > zend_gdata_app->get('https://spreads...', null) #3 > c:\xampp\htdocs\zendgdata-1.12.1\library\zend\gdata\app.php(210): > zend_gdata_app->importurl('https://spreads...', 'zend_gdata_spre...', > null) #4 c:\xampp\htdocs\zendgdata-1.12.1\library\zend\gdata.php(162): > zend_gdata_app->getfeed('https://spreads...', 'zend_gdata_spre...') #5 > c:\xa in c:\xampp\htdocs\zendgdata-1.12.1\library\zend\gdata\app.php > on line 714
any help appreciated! :]
it's been while since i've worked this, believe specific error message you're seeing has service name you're using. 'xapi'
generic service name google services, you're trying access google spreadsheets specifically.
try changing:
$service = 'xapi';
to:
$service = 'wise';
since 'wise'
right clientlogin service name google spreadsheets.
php zend-framework google-docs-api google-spreadsheet-api
No comments:
Post a Comment