持久数据中缺少必需的参数状态

问题描述

我的 PHP-graph-sdk 有问题,我有这些功能

 protected function getFacebook()
    {
        static $facebook = null;
        if($facebook == null){
            $facebook =  new Facebook\Facebook([
                'app_id' => $this->getAppId(),'app_secret' => $this->getAppSecret(),'default_graph_version' => 'v2.10'
            ]);
        }
        return $facebook;
    }
public function getLoginUrl($url)
    {
        $fb = $this->getFacebook();
        
        $helper = $fb->getRedirectLoginHelper();
        
        $autorisations = ['email']; 
        return $helper->getLoginUrl($url,$autorisations);
    }
 public function callback(&$error = null)
    {
        $fb = $this->getFacebook();
        
        $helper = $fb->getRedirectLoginHelper();
        
        try {
            $accesstoken = $helper->getAccesstoken();
        } catch(Facebook\Exception\ResponseException $e) {
            // When Graph returns an error
            $error = 'Graph returned an error: ' . $e->getMessage();
            return false;
        } catch(Facebook\Exception\SDKException $e) {
            // When validation fails or other local issues
            $error = 'Facebook SDK returned an error: ' . $e->getMessage();
            return false;
        }
        ....
  }

我愿意

 $url = $Facebook->getLoginUrl(URL);

在回调文件

$token = $Facebook->callback($error);

当我点击链接时,回调文件被执行,$helper->getAccesstoken();导致此错误: 未捕获的 Facebook\Exceptions\FacebookSDKException:跨站点请求伪造验证失败。持久数据中缺少必需的参数“状态”。

我看过有关此的帖子,但没有修复对我有

编辑: 我目前发现的是:Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data Cross-site request forgery validation failed required param state missing from persistent datahttps://github.com/facebookarchive/php-graph-sdk/issues/1123 https://github.com/facebookarchive/php-graph-sdk/issues/1134

解决方法

最后,我通过在 config.php 中添加相同站点到 Lax 解决了我的问题 ini_set('session.cookie_samesite','Lax');

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...