2014-03-27 74 views
-1
require_once "src/facebook.php"; 

$facebook = new Facebook(); 

$app_id = "xxxxxxxxxxx"; 

$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx"; 

$app_access_token = $app_id . '|' . $app_secret; 

$response = $facebook->api('/user_id/notifications', 'POST', array(

     'template' => 'xxxxxxxxxxxxx', 

     'href' => '', 

     'access_token' => $app_access_token 
    )); 

這是我的工作代碼。但我得到錯誤。Facebook Api Error Missing論據

代碼工作正常,但得到此錯誤。

Warning: Missing argument 1 for Facebook::__construct(), called in 
/xx/xx/xxxx.php on line 6 and defined in/home1/x/xx/xx/facebook.php on line 57 
+0

RTFM:https://developers.facebook.com/docs/php/gettingstarted/#install – CBroe

回答

0

Facebook類實例化應該發生這樣

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

Facebook::__construct()功能需要第一個參數作爲配置數據的數組。

移動你的

$app_id = "xxxxxxxxxxx";  
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx"; 

$app_id = "xxxxxxxxxxx";  
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx"; 
$facebook = new Facebook(array(
    'appId' => $app_id, 
    'secret' => $app_secret, 
    'cookie' => true 
));