开发者

Is this code Oauth 2.0 compatible?

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 flow开发者_如何学Cs 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?


short answer... it is..................

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜