2011-09-02 67 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);