2013-03-03 85 views
0

因此,我使用了Facebook圖形API來拉動我喜歡的Facebook上的頁面,它適用於所有瀏覽器上基於Windows的計算機。但是當檢查另一臺計算機的結果時,它不起作用......任何想法爲什麼? Sandybox模式被禁止過Facebook的api結果只能從我的電腦上工作,而不能在其他電腦上工作

這是我使用的方法,我用圖形API與頁面的想法得到它的信息,包括頁面的封面圖片..下面是一個例子

$pages = $facebook->api("/224837280446"); 

這是在我的基於Windows的筆記本電腦,但不是在Mac上工作..你的幫助將是如此讚賞。

這裏是我的配置

<?php 

    //facebook application 
    $fbconfig['appid' ]  = "xxxxxxxxxxxxxxxxxxxxxxxx"; 
    $fbconfig['secret']  = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 
    $fbconfig['baseurl'] = "http://xxxxxxxxxxx.php"; 

    // 
    if (isset($_GET['request_ids'])){ 
     //user comes from invitation 
     //track them if you need 
    } 

    $user   = null; //facebook user uid 
    try{ 
     include_once "facebook.php"; 
    } 
    catch(Exception $o){ 
     error_log($o); 
    } 
    // Create our Application instance. 
    $facebook = new Facebook(array(
     'appId' => $fbconfig['appid'], 
     'secret' => $fbconfig['secret'], 
     'cookie' => false, 
    )); 

    //Facebook Authentication part 
    $user  = $facebook->getUser(); 
    // We may or may not have this data based 
    // on whether the user is logged in. 
    // If we have a $user id here, it means we know 
    // the user is logged into 
    // Facebook, but we don稚 know if the access token is valid. An access 
    // token is invalid if the user logged out of Facebook. 


    $loginUrl = $facebook->getLoginUrl(
      array(
       'scope'   => 'email,offline_access,publish_stream,user_birthday,user_location,user_work_history,user_about_me,user_hometown', 
       'redirect_uri' => 'http://www.europe-zone.com/members.php' 
      ) 
    ); 

    $logoutUrl = $facebook->getLogoutUrl(); 


    if ($user) { 
     try { 
     // Proceed knowing you have a logged in user who's authenticated. 
     $user_profile = $facebook->api('/me'); 
     } catch (FacebookApiException $e) { 
     //you should use error_log($e); instead of printing the info on browser 
     // d($e); d is a debug function defined at the end of this file 
     $user = null; 
     } 
    } 


    //if user is logged in and session is valid. 
    if ($user){ 
     //get user basic description 
     $userInfo   = $facebook->api("/$user"); 

     //Retriving movies those are user like using graph api 
     try{ 
      $movies = $facebook->api("/$user/movies"); 
      // $pages = $facebook->api("/224837280446"); 
      // $feeds = $facebook->api("/224837280446/feed"); 
     } 
     catch(Exception $o){ 
      d($o); 
     } 

     //update user's status using graph api 
     //http://developers.facebook.com/docs/reference/dialogs/feed/ 
     if (isset($_GET['publish'])){ 
      try { 
       $publishStream = $facebook->api("/$user/feed", 'post', array(
        'message' => "I love thinkdiff.net for facebook app development tutorials. :)", 
        'link' => 'http://ithinkdiff.net', 
        'picture' => 'http://thinkdiff.net/ithinkdiff.png', 
        'name' => 'iOS Apps & Games', 
        'description'=> 'Checkout iOS apps and games from iThinkdiff.net. I found some of them are just awesome!' 
        ) 
       ); 
       //as $_GET['publish'] is set so remove it by redirecting user to the base url 
      } catch (FacebookApiException $e) { 
       d($e); 
      } 
      $redirectUrl  = $fbconfig['baseurl'] . '/members.php?success=1'; 
      header("Location: $redirectUrl"); 
     } 

     //update user's status using graph api 
     //http://developers.facebook.com/docs/reference/dialogs/feed/ 
     if (isset($_POST['tt'])){ 
      try { 
       $statusUpdate = $facebook->api("/$user/feed", 'post', array('message'=> $_POST['tt'])); 
      } catch (FacebookApiException $e) { 
       d($e); 
      } 
     } 

     //fql query example using legacy method call and passing parameter 
     try{ 
      $fql = "SELECT page_id FROM page_fan WHERE uid = me()"; 
      $param = array(
       'method' => 'fql.query', 
       'query'  => $fql, 
       'callback' => '' 
      ); 
      $fqlResult = $facebook->api($param); 
     } 
     catch(Exception $o){ 
      // d($o); 
     } 


// Second query 

try{ 
      $sql = "SELECT page_id FROM page_fan WHERE uid = me()"; 
      $param = array(
       'method' => 'fql.query', 
       'query'  => $sql, 
       'callback' => '' 
      ); 
      $sqlResult = $facebook->api($param); 
     } 
     catch(Exception $o){ 
      // d($o); 
     } 
    } 

    function d($d){ 
     echo '<pre>'; 
     print_r($d); 
     echo '</pre>'; 
    } 
?> 

回答

0

這段代碼是在本地從WAMP在Windows和甲基苯丙胺等在你的Mac上運行?或者你是從一個不在你本地的Web服務器上運行它?

如果它是本地的,我會說檢查你的配置,或者至少嘗試XAMPP和鏡像設置。

相關問題