Facebook SDK returned an error: Cross-site request forgery validation failed. The “state” param from the URL and session do not match

后端 未结 25 1077
南方客
南方客 2020-12-01 01:37

i\'m trying to get Facebook user id using the php sdk like this

$fb = new Facebook\\Facebook([
    \'app_id\' => \'11111111111\',
    \'app_secret\' =>         


        
25条回答
  •  情书的邮戳
    2020-12-01 02:18

    Lots of great answers already mentioned, here is the one which helped for me,

    I found that the problem is Cross-site request forgery validation failed. Required param “state” missing in FB code and here is the solution

    After this line

    $helper = $fb->getRedirectLoginHelper();
    

    Add the below code,

    if (isset($_GET['state'])) {
        $helper->getPersistentDataHandler()->set('state', $_GET['state']);
    }
    

提交回复
热议问题