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.
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