0

I've been searching for an answer for this for quite some time now. I've looked into the other questions here but couldn't find a relevant one to my situation. Googling the question wasn't helpful as well.

Basically, I am using ZF1's Gdata class to access the photos api. This was working a few weeks ago but stopped working (I'm not sure if there was a code change or Google completely stopped the API).

My code is as follows:

private function _loadZendLibraries()
    {
        set_include_path(APP.'vendors');
        require_once('Zend/Loader.php');

        $Zend_Loader = new Zend_Loader();
        $Zend_Loader->loadClass('Zend_Gdata');
        $Zend_Loader->loadClass('Zend_Gdata_ClientLogin');
        $Zend_Loader->loadClass('Zend_Gdata_AuthSub');
        $Zend_Loader->loadClass('Zend_Gdata_Photos');
        $Zend_Loader->loadClass('Zend_Gdata_Photos_UserQuery');
        $Zend_Loader->loadClass('Zend_Gdata_Photos_AlbumQuery');
        $Zend_Loader->loadClass('Zend_Gdata_Photos_PhotoQuery');
        $Zend_Loader->loadClass('Zend_Gdata_App_Extension_Category');

    }


function checkGoogleImages(){
    $this->_loadZendLibraries();
    $service_name = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
        $user = '********@gmail.com';
        $pass = '********';

        try {
            $this->client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service_name);
        } catch (Zend_Gdata_App_Exception $e) {
            $this->Session->setFlash("Error: " . $e->getMessage(). "<br /> You need go to Google+ => Settings => Applications and APPROVE the application to connect.", 'flash_failure');
            $this->Session->delete('GOOGLE_USER');
            $this->redirect($this->referer());
        }

        print "<pre>";
        print_r($this->client);
        exit;
}

On one server it gives:

Notice (8): Undefined offset: 1 [APP/vendors/Zend/Gdata/ClientLogin.php, line 150]

And on the other:

Notice (8): Undefined offset: 1 [APP/vendors/Zend/Gdata/ClientLogin.php, line 150] Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 403 Authorization required' in /home/home/mysite/app/vendors/Zend/Gdata/App.php:717 Stack trace: #0 /home/home/mysite/app/vendors/Zend/Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'https://picasaw...', Array, NULL, NULL, NULL) #1 /home/home/mysite/app/vendors/Zend/Gdata/App.php(883): Zend_Gdata->performHttpRequest('GET', 'https://picasaw...', Array) #2 /home/home/mysite/app/vendors/Zend/Gdata/App.php(771): Zend_Gdata_App->get('https://picasaw...', NULL) #3 /home/home/mysite/app/vendors/Zend/Gdata/App.php(213): Zend_Gdata_App->importUrl('https://picasaw...', 'Zend_Gdata_Phot...', NULL) #4 /home/home/mysite/app/vendors/Zend/Gdata.php(162): Zend_Gdata_App->getFeed('https://picasaw...', 'Zend_Gdata_Phot...') #5 /home/home/mysite/app/vendors/Zend/Gdata/Photos.php(175): Zend_Gdata->getFeed('https://picasaw...', 'Zend_Gdata_Phot...') #6 /home/home/mysite/app/controllers/photos_ in /home/home/mysite/app/vendors/Zend/Gdata/App.php on line 717

NOTE: I am using CakePHP 1.3 along with Zend Framework 1.12.7. I am only trying to retrieve images from Google Plus for a certain account. The user enters their email and password and the application should extract their images.

I cannot seem to find the answer for this. Did google completely stop the API? Is something in the usage incorrect?

Thanks in advance.

Adon
  • 345
  • 1
  • 12
  • possible duplicate of [Insert photo ERROR: The remote server returned an error: (403) Forbidden](http://stackoverflow.com/questions/30567126/insert-photo-error-the-remote-server-returned-an-error-403-forbidden) – Linda Lawton - DaImTo Jun 03 '15 at 13:23
  • 1
    you need to switch to Oauth2. client login was shut down. – Linda Lawton - DaImTo Jun 03 '15 at 13:23
  • @DalmTo this is not a duplicate of that question. I checked it and it's not relevant in many aspects. I am using ZendFramework 1 Gdata class to connect using `Zend_Gdata_ClientLogin` to retrieve data only. The other example deals with .NET and inserting images dynamically through the API. There are so many areas of difference that might cause the problem other than basic usage (authentication method, zf version, google itself, etc...) – Adon Jun 03 '15 at 13:55
  • 1
    My point is that the Client Login end point on googles end has been turned off. You cant access any of the Google APIs with Login and Password. You must switch to Open authentication. – Linda Lawton - DaImTo Jun 03 '15 at 14:00

1 Answers1

5

Zend_Gdata uses ClientLogin which was deprecated as of April 20, 2012 and turned off on May 26 2015. This code will not longer work you need to switch to using Oauth2.

You can use the current Google PHP client library to authenticate then use the access token created there to access it. This answer may help

Community
  • 1
  • 1
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • I guess it is true that it has been turned off. Yet the link you have provided is actually for the .NET framework and not the php library. Please edit that so i can accept the answer. – Adon Jun 04 '15 at 08:49
  • 1
    That was fast! Thanks for the help. – Adon Jun 04 '15 at 08:51