2011-09-21 36 views
0

我想要瘋了,我想!Facebook PHP SDK - Web應用程序正在一臺機器上工作,但沒有任何其他的?

我在我的工作機器上登錄了我的個人Facebook帳戶,我使用的應用程序正常工作,但在任何其他機器上登錄爲我,應用程序管理員或任何其他人頁面似乎不斷刷新與url中的狀態參數只是旋轉起來並在頁面加載之間變化。 (我有一臺筆記本電腦坐在我的桌子上,都使用Firefox也是)

我確定它在所有測試它的機器上工作的那天。今天它開始有一個錯誤,但我不記得錯誤代碼,但它是與重新直接url不屬於域,但現在似乎並沒有出現。

我不是應用程序的管理員。

下面是相關代碼:

<? 
error_reporting(0); 

// Facebook PHP SDK 
include_once "src/facebook.php"; 

// app id and seret from the facebook app 
$appId = 'xxxxxxxxxxxxxx'; 
$secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; 

$facebook = new Facebook(array(
    'appId' => $appId, 
    'secret' => $secret, 
    'cookie' => true, 
)); 

//Facebook Authentication part 
$user  = $facebook->getUser(); 
$loginUrl = $facebook->getLoginUrl(
    array(
     'canvas' => 1, 
     'fbconnect' => 0, 
     'scope'  => 'user_status,publish_stream,user_photos' 
    ) 
); 

if ($user) 
{ 
    try 
    { 
      // page id and the feed we want 
    $user_feed = $facebook->api('PAGENUMBER/feed'); 

    echo "<div id=\"graph\">"; 
    $count = 0; 
    for ($i=0; $i<25; $i++) 
    { 
     // only want statuses - no videos, events, links etc. 
     if ($user_feed['data'][$i]['type'] == "status") 
       // just grabbing stuff and echoing it out 
       // blah blah blah 
      } 
     } 
    catch (FacebookApiException $e) 
    { 
      $user = null; 
     } 
    // close graph div 
    echo "</div>"; 
} 

// if the user is not logged in then redirect to login page 
if (!$user) 
{ 
    echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>"; 
    exit; 
} 
?> 
+1

只需注意:不要使用PHP短標籤。 –

+0

謝謝,我通常不會,不記得那是不是我。但現在改變了。 – martincarlin87

回答

0

這是一個痛苦的,但拿出if ($user)trycatch和登錄重定向和所有似乎工作。

相關問題