gmail oauth imap zend 从 gmail 而不是会话检索

发布于 2024-10-30 13:21:08 字数 746 浏览 0 评论 0原文

我计划使用 google oauth IMAP 注册我的网站。 我使用 zend 框架也是如此。 http://code.google.com/p/google-mail -xoauth-tools/wiki/PhpSampleCode 我也正在起诉三足方法来注册 当我浏览示例 Threelegged.php 时。 我发现它有电子邮件地址收件箱,他将其保留在会话中并访问 gmail 帐户,一旦他返回,他就会从会话中删除电子邮件 ID

$email_address = $_SESSION['email_address'];

第 121 行

$config = new Zend_Oauth_Config();

$config->setOptions($options);

$config->setToken($accessToken);

$config->setRequestMethod('GET');

$url = 'https://mail.google.com/mail/b/' 。 $电子邮件地址。 '/imap/';

我的要求是我不想在会话中保留电子邮件地址,而是希望在中检索给定的 gmail 地址 $电子邮件地址。 我怎样才能做到这一点? Zend框架中有支持它的函数吗?

Im planning to use google oauth IMAP to sign up for my website.
Im using zend framework for the same.
http://code.google.com/p/google-mail-xoauth-tools/wiki/PhpSampleCode
Also im suing 3 legged approach to sign up
When i go through the sample threelegged.php.
I find that i t has email address inbox and he keeps it in a session and goes to access the gmail account and once he returns back he retireves the email id from the session

$email_address = $_SESSION['email_address'];

Line No.121

$config = new Zend_Oauth_Config();

$config->setOptions($options);

$config->setToken($accessToken);

$config->setRequestMethod('GET');

$url = 'https://mail.google.com/mail/b/' .
$email_address .
'/imap/';

My requirement is i do not want to have email address to be kept in session instead i want the given the gmail address to be retrieved in
$email address.
How can i do that ?
Is any function supporting it in Zend framework?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

む无字情书 2024-11-06 13:21:08

http://sites.google.com/site/oauthgoog/Home/emaildisplayscope

您需要将授权 URL 与您请求获取数据的其他 URL 一起包含在内:
https://www.googleapis.com/auth/userinfo.email

然后当你实际上获取授权令牌,您可以这样做:

// Get access token from session after authorization process is complete.
$accessToken = unserialize($_SESSION['ACCESS_TOKEN']);

// Retrieve email address using Access Token
$erequest = $accessToken->getHttpClient($options);
$erequest->setUri('https://www.googleapis.com/userinfo/email');
$erequest->setMethod(Zend_Http_Client::GET);
$ereturn = $erequest->request();
parse_str($ereturn->getBody(), $earray);
$email_address = $earray['email'];

// Retrieve mail using Access Token
$config = new Zend_Oauth_Config();
$config->setOptions($options);
$config->setToken($accessToken);
$config->setRequestMethod('GET');
$url = 'https://mail.google.com/mail/b/' .
   $email_address . 
   '/imap/';

这是在验证用于访问数据的令牌之后。然后,该电子邮件地址可用于您的邮件请求或任何需要该电子邮件地址的其他内容。

http://sites.google.com/site/oauthgoog/Home/emaildisplayscope

You will need to include the authorization url with your other urls you are asking permission to get data from:
https://www.googleapis.com/auth/userinfo.email

Then when you actually get the authorized token you can do it like this:

// Get access token from session after authorization process is complete.
$accessToken = unserialize($_SESSION['ACCESS_TOKEN']);

// Retrieve email address using Access Token
$erequest = $accessToken->getHttpClient($options);
$erequest->setUri('https://www.googleapis.com/userinfo/email');
$erequest->setMethod(Zend_Http_Client::GET);
$ereturn = $erequest->request();
parse_str($ereturn->getBody(), $earray);
$email_address = $earray['email'];

// Retrieve mail using Access Token
$config = new Zend_Oauth_Config();
$config->setOptions($options);
$config->setToken($accessToken);
$config->setRequestMethod('GET');
$url = 'https://mail.google.com/mail/b/' .
   $email_address . 
   '/imap/';

This is after authenticating a token for accessing the data. Then the email address can be used for your mail request or anything else that requires the email address.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文