$facebook->getSession(); not working. No idea why?

后端 未结 4 2098
忘了有多久
忘了有多久 2021-01-26 08:24
  \'130407366991766\',
  \'secret\' => \'**         


        
相关标签:
4条回答
  • 2021-01-26 08:56

    You need to give the Api Key to the constructor. Not the App Id.

    0 讨论(0)
  • 2021-01-26 09:02

    I had exactly the same problem. My whole app was broken because getSession() was no longer functioning.

    I downloaded the latest version of the PHP SDK and used the example to initialize the user session.

    Basically, the session is initialized as soon as you create the Facebook object. So from the example code, when you call.

    $facebook = new Facebook(array(
      'appId'  => '191149314281714',
      'secret' => '73b67bf1c825fa47efae70a46c18906b',
    ));
    

    You already have a session. To get the user ID, you just call:

    $uid = $facebook->getUser();
    

    If the result of that call is 0, then the user is not logged in.

    0 讨论(0)
  • 2021-01-26 09:10

    Facebook have changed the way you call the API and the old REST API calls are being depracated. This means that the getSession() method doesn't work anymore.

    0 讨论(0)
  • 2021-01-26 09:23

    Facebook Change to OAuth2 and GetSession not working download new base_facebook.php and facebook.php from developers PHP Sdk and replace login procedure to:

    if( $userfb = $facebook->getUser() ){ 
       try{
            $UserProfile = $facebook->api('/me');
       }catch (FacebookApiException $e) {
          $userfb      = null;
          $UserProfile = null;
    }
    

    Is work in my site the new version can't show a fb:login-button with perms parameter :( and i can't repair

    0 讨论(0)
提交回复
热议问题