【发布时间】:2015-08-24 16:26:33
【问题描述】:
既然 Google 已经开始使用 OAuth2,这里有人知道如何访问 Google Photos API 吗?他们开发者网站中的 PHP 客户端库现已过时且无法正常工作!
我已使用 OAuth 与 Google 云端硬盘一起使用,但照片无法使用! :(
首先我使用Google_Client 成功验证用户。然后在重定向页面中我正在尝试以下操作:
require_once("Google/Client.php");
//set up path for Zend GData, because Google Documentation uses that lib
$clientLibraryPath = '/path/to/ZendGData/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_Photos');
try
{
$authCode = $_GET['code']; //authorization code returned from google
//next create google OAuth Client object and validate...
$webAuth= new Google_Client();
$webAuth->setClientId($clientId);
$webAuth->setClientSecret($clientSecret);
$webAuth->authenticate($authCode); //this authenticate() works fine...
//now my problem is HOW do I tie this to GData API for Picasa :(
//I tried following but it throws error
//*Token invalid - Invalid token: Request token used when not allowed.*
$client = Zend_Gdata_AuthSub::getHttpClient($authCode);
$gp = new Zend_Gdata_Photos($client, "GData:2.0");
$userFeed = $gp->getUserFeed("default");
我还尝试了一堆第三方库,尝试将我的 $webAuth 连接到 Zend_GData_Photos
谁能帮帮我?我束手无策....我不敢相信当 Google 将身份验证更新为 OAuth 时,他们会留下一个功能齐全的库(PicasaWeb PHP API Ver 1.0)。
【问题讨论】:
标签: php api oauth gdata google-data-api