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
) );
这是我的工作代码。但我得到了错误。
代码工作正常,但收到此错误。
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 :(得分:0)
Facebook类实例化应该以这种方式发生
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_APP_SECRET,
'cookie' => true
));
Facebook::__construct()
函数需要第一个param作为配置数据数组。
移动你的
$app_id = "xxxxxxxxxxx";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
作为
$app_id = "xxxxxxxxxxx";
$app_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));