此代码与 Oauth 2.0 兼容吗?
Facebook 宣布所有应用程序必须在 2011 年 10 月 1 日之前迁移到 OAuth 2.0
2011 年 10 月 1 日 OAuth 2.0 迁移正如我们在 5 月份宣布的那样,所有应用程序 必须迁移到 OAuth 2.0 进行身份验证并期望加密 访问令牌。旧的SDK,包括旧的JS SDK和旧的iOS SDK 将不再起作用。
在这里阅读更多信息:https://developers.facebook.com/docs/oauth2-https- 。
现在我对所有不同的流程和版本感到非常困惑 我正在进行一个简单的身份验证,看起来基本上像这样(我删除了非必要的部分)
## setup ###
$url = "https://graph.facebook.com/oauth/authorize?client_id=".$this->appid."&redirect_uri=".$myurl;
header("Location: $url");
exit();
,当用户返回时...
## authentication check ##
$code = isset($_GET["code"]) ? $_GET["code"] : false;
if(!$code) {
// user has not authenticated yet, lets return false so setup redirects him to facebook
return false;
}
$url = "https://graph.facebook.com/oauth/access_token?client_id=".$this->appid."&redirect_uri=";
$redirecturl = urlencode($redirecturl);
$url .= $redirecturl;
$url .= "&client_secret=".$this->secret;
$url .= "&code=".$code;
$data = $this->get_data($url); // fetches content over https
parse_str($data,$data);
$token = $data['access_token'];
$data = $this->get_data('https://graph.facebook.com/me?access_token='.urlencode($token));
$data = json_decode($data);
$id = $data->id;
if($id > 0) {
// yeah authenticated!
} else {
// login failed
}
此方法是否已准备好进行强制迁移?
Facebook announced that all apps must migrate to OAuth 2.0 by 1st of October 2011
October 1, 2011 OAuth 2.0 Migration As we announced in May, all apps
must migrate to OAuth 2.0 for authentication and expect an encrypted
access token. The old SDKs, including the old JS SDK and old iOS SDK
will no longer work.
Read more here: https://developers.facebook.com/docs/oauth2-https-migration/
Now I am pretty confused by all the different flows and versions. I have a simple authentication going on that looks basically like this (I stripped the un essential parts)
## setup ###
$url = "https://graph.facebook.com/oauth/authorize?client_id=".$this->appid."&redirect_uri=".$myurl;
header("Location: $url");
exit();
and when the user returns...
## authentication check ##
$code = isset($_GET["code"]) ? $_GET["code"] : false;
if(!$code) {
// user has not authenticated yet, lets return false so setup redirects him to facebook
return false;
}
$url = "https://graph.facebook.com/oauth/access_token?client_id=".$this->appid."&redirect_uri=";
$redirecturl = urlencode($redirecturl);
$url .= $redirecturl;
$url .= "&client_secret=".$this->secret;
$url .= "&code=".$code;
$data = $this->get_data($url); // fetches content over https
parse_str($data,$data);
$token = $data['access_token'];
$data = $this->get_data('https://graph.facebook.com/me?access_token='.urlencode($token));
$data = json_decode($data);
$id = $data->id;
if($id > 0) {
// yeah authenticated!
} else {
// login failed
}
Is this method ready for the compulsory migration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的回答......是......
short answer... it is..................