0

我正在为我的应用程序使用此代码以允许用户登录以及获取应用程序权限以创建和编辑用户的事件,并且工作正常,但是当我今天尝试时,页面不断刷新无限以及每次更改验证码。我不知道发生了什么事。

<?php
   // Include facebook php api 
   require_once("lib/facebook.php");

    // Setup app configuration
    $config = array();
    $config['appId'] = 'APP_ID';
    $config['secret'] = 'APP_SECRET';
    $config['cookie'] = true;
    $config['fileUpload'] = true;

    // set app id & canvas page for location variable
    $app_id = 'APP_ID';
    $canvas_page = "https://apps.facebook.com/mixityhc/";

      $location = "https://www.facebook.com/dialog/oauth?client_id=" 
         . $app_id . "&redirect_uri=" . urlencode($canvas_page) . "&scope=publish_stream,email,create_event,rsvp_event,user_events,friends_events";

  // create new instance of facebook object
  $facebook = new Facebook($config);

    // Get user id
    $fbID = $facebook->getUser();

    // Get the current access token
    $access_token = $facebook->getAccessToken();

    // check if we have valid user
 if ($fbID) {
     try {
          // Proceed knowing you have a logged in user who's authenticated.
         $fb_user_profile = $facebook->api('/me');   

      } catch (FacebookApiException $e) {
          $fbID = NULL;
          // seems we don't have enough permissions
          // we use javascript to redirect user instead of header() due to Facebook bug
          print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';

         // kill the code so nothing else will happen before user gives us permissions
         die();
      }

  } else {
      // seems our user hasn't logged in, redirect him to a FB login page

     print '<script language="javascript" type="text/javascript"> top.location.href="'. $location .'"; </script>';

     // kill the code so nothing else will happen before user gives us permissions
     die();
 }

 // Get user email address
 $email = $fb_user_profile['email'];

任何帮助将不胜感激谢谢

4

1 回答 1

0

好吧,我想通了。Facebook API 已更新以修复 Facebook 中的一个明显错误。所以我上传了新文件(特别是证书)并且它有效。以防万一其他人遇到同样的问题。

谢谢

于 2012-12-10T23:14:40.490 回答