我试图通过 o的授权来获取邮件(地图)。 我已获得工作授权,但我无法收回电子邮件。 我的理解是,这应该是可行的。 但谷歌没有收回邮件的复印件。 然而,我发现:
https://developers.google.com/google-apps/gmail/oauth_overview
也就是说:
Accessing mail using IMAP and sending mail using SMTP is often done using existing IMAP and SMTP libraries for convenience. As long as these libraries support the Simple Authentication and Security Layer (SASL), they should be compatible with the OAuth mechanism supported by Gmail. In addition to using a library which supports IMAP and SMTP, developers also will want to use one of the many existing libraries for handling OAuth
任何人都知道一个能够使用的现有图书馆,也有一些文件。 采用gogle-api-php-客户。
法典
session_start();
ini_set( display_errors ,1);
error_reporting(-1);
require_once ../../src/apiClient.php ;
$client = new apiClient();
$client->setApplicationName( Mailendar );
$client->setScopes("http://www.google.com/m8/feeds/");
// Documentation: http://code.google.com/apis/gdata/docs/2.0/basics.html
// Visit https://code.google.com/apis/console?api=contacts to generate your
// oauth2_client_id, oauth2_client_secret, and register your oauth2_redirect_uri.
$client->setClientId( secret );
$client->setClientSecret( secret );
$client->setRedirectUri( secret );
$client->setDeveloperKey( secret );
if (isset($_GET[ code ])) {
$client->authenticate();
$_SESSION[ token ] = $client->getAccessToken();
$redirect = http:// . $_SERVER[ HTTP_HOST ] . $_SERVER[ PHP_SELF ];
header( Location: . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION[ token ])) {
echo "token is set";
$client->setAccessToken($_SESSION[ token ]);
}
if (isset($_REQUEST[ logout ])) {
unset($_SESSION[ token ]);
$client->revokeToken();
}
if ($client->getAccessToken()) {
MAGIC HAPPENS HERE!!!...but is unkown for me ofc
// The access token may have been updated lazily.
$_SESSION[ token ] = $client->getAccessToken();
} else {
$auth = $client->createAuthUrl();
}
if (isset($auth)) {
print "<a class=login href= $auth >Connect Me!</a>";
} else {
print "<a class=logout href= ?logout >Logout</a>";
}
感谢!