很长一段时间以来,我一直在寻找答案.我在这里查看了其他问题,但找不到与我的情况相关的问题.谷歌搜索这个问题也没有用.
基本上,我使用ZF1的Gdata类来访问照片api.这是几个星期前工作但停止工作(我不确定是否有代码更改或谷歌完全停止了API).
我的代码如下:
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;
}
Run Code Online (Sandbox Code Playgroud)
在一台服务器上它给出:
注意(8):未定义的偏移量:1 [APP/vendors/Zend/Gdata/ClientLogin.php,第150行]
另一方面: …