我是新開發Facebook應用程序的新手。我遇到以下問題,如果有人能幫忙,我會很高興。在hello world facebook應用程序中require_once有問題
我已經在Facebook上註冊了我的應用程序,並將代碼和php客戶端庫上傳到託管服務器。如果我使用下面的代碼,那麼一切工作正常。
<?php
require_once('./facebook/php/facebook.php');
/* initialize the facebook API with your application API Key
and Secret */
$facebook = new Facebook("<my_api_key>","<my_secret_key>");
$user = $facebook->require_login();
echo "<p>Your User ID is: $user</p>";
echo "<p>Your name is: <fb:name uid=\"$user\" useyou=\"false\"/></p>";
echo "<p>You have several friends: </p>";
$friends = $facebook->api_client->friends_get();
echo "<ul>";
foreach ($friends as $friend) {
echo "<li><fb:name uid=\"$friend\" useyou=\"false\" /></li>";
}
echo "</ul>";
/* Echo some information that will
help us see what's going on with the Facebook API: */
echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";
?>
但是,如果我把代碼分成兩個文件如下然後我就得到了一個空白的畫布,當我瀏覽到http://apps.facebook.com/myapp
appinclude.php
<?php
require_once('./facebook/php/facebook.php');
/* initialize the facebook API with application API Key
and Secret */
$facebook = new Facebook("<my_api_key>","<my_secret_key>");
$user = $facebook->require_login();
?>
指數。 php
<?php
require_once('./appinclude.php');
echo "<p>Your User ID is: $user</p>";
echo "<p>Your name is: <fb:name uid=\"$user\" useyou=\"false\"/></p>";
echo "<p>You have several friends: </p>";
$friends = $facebook->api_client->friends_get();
echo "<ul>";
foreach ($friends as $friend) {
echo "<li><fb:name uid=\"$friend\" useyou=\"false\" /></li>";
}
echo "</ul>";
/* Echo some information that will
help us see what's going on with the Facebook API: */
echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";
?>
有什麼辦法解決這個問題?
謝謝。
@MikeTJ,也許樹的輸出會照亮我們。 – Don