php zend gdata - 使用 oauth 获取谷歌文档列表

2021-12-29 00:00:00 oauth google-api php zend-framework gdata

我用我这样设置的有效令牌进行了会话:

I've got my session with the valid token that i set up this way :

$session_token = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
// Store the session token in our session.
$_SESSION['cal_token'] = $session_token;

然后我希望能够做到这一点:

Then i want to be able to do this:

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$docs = new Zend_Gdata_Docs($client);
$feed = $docs->getDocumentListFeed();

但是使用令牌.而不是使用 user/pass/service 进行身份验证

But using the token. Instead of the authentication with user/pass/service

我已经看过一些这样的例子,但我没有找到任何让它工作的方法.

I already looked at some example of this but i didn't find any way to make it work.

谢谢大家!

推荐答案

    // Retrieve user's list of Google Docs
    $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['cal_token']);
    $docs = new Zend_Gdata_Docs($client);
    $feed = $docs->getDocumentListFeed();
    foreach ($feed->entries as $entry) {
      echo "$entry->title
";
    }

相关文章