无法通过facebook php sdk登录

时间:2017-05-01 06:38:40

标签: php facebook facebook-php-sdk

登录到fb php sdk时,我遇到了这样的错误 此页面无效

www.facebook.com目前无法处理此请求。 HTTP ERROR 500

我已经根据facebook app和key正确配置了我的应用程序和我的密钥。

我不知道为什么会抛出这种错误。请帮帮我

// init app with app id and secret
   FacebookSession::setDefaultApplication( 
     myappkey,mysecretkey );
  // login helper with redirect_uri
   $helper = new 
  FacebookRedirectLoginHelper('http://demos.krizna.com/1353/fbconfig.php' );
  try {
  $session = $helper->getSessionFromRedirect();
 } catch( FacebookRequestException $ex ) {
  // When Facebook returns an error
 } catch( Exception $ex ) {
  // When validation fails or other local issues
 }
   // see if we have a session
 if ( isset( $session ) ) {
  // graph api request for user data
 $request = new FacebookRequest( $session, 'GET', '/me' );
 $response = $request->execute();
 // get response
    $graphObject = $response->getGraphObject();
    $fbid = $graphObject->getProperty('id');              // To Get Facebook ID
    $fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
    $femail = $graphObject->getProperty('email');    // To Get Facebook email ID
/* ---- Session Variables -----*/
    $_SESSION['FBID'] = $fbid;           
    $_SESSION['FULLNAME'] = $fbfullname;
    $_SESSION['EMAIL'] =  $femail;
/* ---- header location after session ----*/
    header("Location: index.php");
} else {
  $loginUrl = $helper->getLoginUrl();
 header("Location: ".$loginUrl);
}

0 个答案:

没有答案