Facebook cookie 和 oauth 2.0 更改 [英] Facebook cookie and oauth 2.0 changes

查看:28
本文介绍了Facebook cookie 和 oauth 2.0 更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个功能曾经对我有用,直到有一天 facebook 决定强制执行一些更改.

This function used to work for me until the other day when facebook decided to enforce some changes.

    function get_facebook_cookie() {
    $app_id             = '[MyAppID]';
    $application_secret = '[MyAppSecrect]';

    if(isset($_COOKIE['fbs_' . $app_id])){
        $args = array();
        parse_str(trim($_COOKIE['fbs_' . $app_id], '\"'), $args);
        ksort($args);
        $payload = '';
        foreach ($args as $key => $value) {
                if ($key != 'sig') {
                $payload .= $key . '=' . $value;
                }
        }
        if (md5($payload . $application_secret) != $args['sig']) {
                return null;
        }
        return $args;
        } else {
         return null;
        }
}

我能够轻松获得 FB 用户的访问令牌

I was the able to get the FB users access token as easily as

$cookie['access_token']

现在我似乎无法再检索此信息了.

Now it doesn't seem that I'm able to retrieve this info anymore.

我成功地(轻松地)对我的 javascript 代码进行了所需的更改,但我对 php 方面有点困惑.作为一个快速的旁注,我正在使用 codeigniter 并且我在尝试让 FB PHP SDK 运行良好时遇到了很多麻烦,而且我还没有看到任何将 PHP 3 SDK 集成到 codeigniter 中的示例,所以我寻找一个快速而肮脏的解决方案,使我能够从 cookie 中获取访问令牌,从而允许我使用以下对 Facebooks API 的调用:

I was successfully (easily) able to make the required changes to my javascript code, but I'm kind of stumped on the php side. As a quick side note I'm using codeigniter and I've had a lot of trouble trying to get the FB PHP SDK to play nice, also I havne't seen any examples of integrating the PHP 3 SDK into codeigniter so I'm looking for a quick and dirty solution that will allow me to get the access token from the cookie thus allowing me to use the following call to Facebooks API:

'https://api.facebook.com/method/friends.getAppUsers?access_token=' . $cookie['access_token'];

非常感谢任何帮助.

推荐答案

这是因为facebook将cookie名称从fbs_改为fbsr_.

it's because facebook change cookie name from fbs_ to fbsr_.

但还有更多变化.只需按照此步骤

But there was more changes. Just follow this steps

这篇关于Facebook cookie 和 oauth 2.0 更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆