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

后端 未结 25 1018
南方客
南方客 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:13

    The error is triggered if origin hostname is different than the target hostname [as Souch mentioned]. When visitors typed in URL address box as "http://website.com" that is different from "http://www.website.com". We redirect them to the correct URL, by adding the following codes at topmost position before session_start().

      if($_SERVER['HTTP_HOST']!=='www.website.com'){
      header('location: http://www.website.com');
      }
    

提交回复
热议问题