Jump to content

Google data API in PHP


ursvmg

Recommended Posts

Hi everyone,

 

I'm trying to build a web application in PHP that takes scanned images from user and convert it in to text document.

 

I would like to use Google's Documents List Data API inside my PHP scripts.

 

The online application is available at http://googlecodesamples.com/docs/php/ocr.php.

 

I do not know where to start with and how to invoke the API.

 

Could anyone please direct me.. ? If anyone has any samples, kindly provide.

 

 

Link to comment
https://forums.phpfreaks.com/topic/210485-google-data-api-in-php/
Share on other sites

Actually, I am also working on google API. I try to retrieve documents from my google docs. I found the Zend framework for G_data. It contain the API to access google docs. However, i am stucking with using the error message: `invalid token`. It makes me suspect that the API can only be used for Google Apps Premium edition. There are ways that you don't need o use the API. You just hard-core coding, this link show that: http://code.google.com/apis/spreadsheets/data/3.0/developers_guide_protocol.html#ListingSpreadsheets . However, I hvnt tried it yet coz I am not very good at sending POST and GET HTTP Request. If you know any way to work about it, please enlighten me.

<?php

 

    foreach (glob("../libraries/Zend/Gdata/*.php") as $filename) {

 

        require_once($filename);

 

    }

 

 

    $email = 'username@domain';

   

    $passwd = 'pass';

   

    try {

   

      $httpClient = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, 'cl');

   

    } catch (Zend_Gdata_App_CaptchaRequiredException $cre) {

   

        echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";

   

        echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";

   

    } catch (Zend_Gdata_App_AuthException $ae) {

   

      echo 'Problem authenticating: ' . $ae->exception() . "\n";

   

    }

   

 

    try{

       

        $gdClient = new Zend_Gdata_Spreadsheets($httpClient);

        print "== Available Spreadsheets ==\n";

       

        //the error is from this line

        $feed = $gdClient->getSpreadsheetFeed();

       

    } catch(Zend_Gdata_App_HttpException $exception) { 

   

        echo "Error: " . $exception->getResponse()->getRawBody(); 

   

    }

   

?>

It is solved, the correct code is:

 

<?php

 

    foreach (glob("../libraries/Zend/Gdata/*.php") as $filename) {

 

        require_once($filename);

 

    }

 

 

    $email = 'username@domain';

 

    $passwd = 'pass';

 

    try {

 

      $httpClient = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME);

 

    } catch (Zend_Gdata_App_CaptchaRequiredException $cre) {

 

        echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";

 

        echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";

 

    } catch (Zend_Gdata_App_AuthException $ae) {

 

      echo 'Problem authenticating: ' . $ae->exception() . "\n";

 

    }

 

 

    try{

     

        $gdClient = new Zend_Gdata_Spreadsheets($httpClient);

        print "== Available Spreadsheets ==\n";

     

        //the error is from this line

        $feed = $gdClient->getSpreadsheetFeed();

     

    } catch(Zend_Gdata_App_HttpException $exception) {

 

        echo "Error: " . $exception->getResponse()->getRawBody();

 

    }

 

?>

 

Those are links for reference of google docs API:

http://code.google.com/apis/documents/docs/1.0/developers_guide_php.html

http://framework.zend.com/manual/en/zend.gdata.spreadsheets.html

http://code.google.com/apis/spreadsheets/data/1.0/developers_guide_php.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.