2012-12-10 59 views
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']; 

任何幫助,將不勝感激謝謝

回答

0

好吧,我想通了。 Facebook API已更新,以修復Facebook中的明顯錯誤。所以我上傳了新的文件(特別是證書),它的工作。以防萬一其他人遇到同樣的問題。

謝謝