Search code examples
facebookfacebook-graph-apifacebook-access-token

facebook manage pages details


I am trying to get access of facebook pages through php SDK

Using php-sdk-4.0.13

Facebook app version v2.2

And redirecting url like this https://www.facebook.com/v2.2/dialog/oauth?redirect_uri=http//www.example.com/john114614/settings&state=5255ad86fea19ab0e8d61776890d0224&scope=manage_pages&client_id=558252720931906&ret=login&sdk=php-sdk-4.0.13&ext=1431067051&hash=AeYVfkUZEGLy0wD_

Its stay at 302 status and redirecting to http//www.example.com/john114614/settings?code=blahbla.......

App id is perfect and more over this problem faced from last 5-6 days before that its working fine.

Please help me how i can resolve this issue?

Thanks


Solution

  • Solution for above problem

    use Facebook\FacebookSession;
    
    use Facebook\FacebookRedirectLoginHelper;
    
    use Facebook\GraphUser;
    
    use Facebook\FacebookRequestException;
    
    FacebookSession::setDefaultApplication('appid84', '0secret0a626c6');
    
    $helper = new FacebookRedirectLoginHelper('http://tmd.local/fblogin.php');
    
    try {
    
      $session = $helper->getSessionFromRedirect();
    
    
    }
     catch(FacebookRequestException $ex) {
    }
    
     catch(\Exception $ex) {
    }
    if ($session) {
    
      var_dump($session);
    
    }
    
    else
    {
      $loginUrl = $helper->getLoginUrl();
    
     header("location:".$loginUrl);
    
      exit;
    }