2011-09-02 66 views
4

使用Google的教程,我尝试使用OAuth 2.0身份验证方法访问Blogger API。我已成功通过OAuth进行身份验证,但我不明白如何访问API。使用OAuth 2.0访问Google API(特别是Blogger)(PHP)

他们所有的例子跑出对象$ gdclient - 这,如果您使用的AuthSub方法,设置为Zend_Gdata_AuthSub :: getHttpClient($ _ SESSION [ 'sessionToken']);

但是,如果您使用OAuth2.0进行身份验证,我似乎无法找到要设置$ gdclient的内容!请帮忙吗?其余的例子很简单,但正如我所提到的,它们都是从$ gdclient运行的,而我迄今为止还没有设置它。

的Blogger API教程:http://code.google.com/apis/blogger/docs/1.0/developers_guide_php.html

的OAuth 2.0:http://code.google.com/apis/accounts/docs/OAuth2.html

谢谢!

+5

我回答我自己的问题,我想。 它看起来像是我没有使用$ gdclient和所有的zend框架 - 我只是调用他们调用的链接的调用。我在https://github.com/jcleblanc/oauth/tree/master/oauth2-php-google发现了这个完整的端到端示例,但它很难找到。 如果有人有任何其他意见,我一直在寻找更好的信息!谢谢! –

+0

嗨,我处于相同的情况寻找一种方式来查看谷歌播放安卓市场的销售报告。你知道谷歌有一些官方API。看看这个页面https://developers.google.com/accounts/docs/OAuth2WebServer –

回答

-2

形成标题:3.c. ClientLogin username/password authentication

$user = '[email protected]'; 
$pass = 'secretPasswd'; 
$service = 'blogger'; 

$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null, 
    Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null, 
    Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE'); 
$gdClient = new Zend_Gdata($client);