Facebook通知 - 是否需要许可?

Nik*_*kov 5 facebook facebook-graph-api facebook-javascript-sdk

以下是我在文档中看到的内容:

Apps can send notifications to any existing user that has authorized the app. No special or extended permission is required.
Run Code Online (Sandbox Code Playgroud)

好的听起来不错.我正在使用JS SDK,这是我正在尝试做的事情:

FB.api('/me/notifications?access_token=' + window.accessToken + '&href=test&template=test', function(response) {
        console.log(response);
});
Run Code Online (Sandbox Code Playgroud)

这就是我得到的:

"(#200) The "manage_notifications" permission is required in order to query the user's notifications."
Run Code Online (Sandbox Code Playgroud)

我尝试用我的应用程序的真实域名替换href参数.使用我的Facebook ID代替"/ me /"也没什么区别.救命!

我已经尝试添加manage_notifications权限(但仍然不起作用......),但我的问题是为什么它在文档中反过来说?

编辑:去PHP:

<?php 

include_once('sdk/facebook.php');

$user = $_POST['user'];
$message = $_POST['message'];

$config = array();
$config['appId'] = '609802022365238';
$config['secret'] = '71afdf0dcbb5f00739cfaf4aff4301e7';

$facebook = new Facebook($config);
$facebook->setAccessToken($config['appId'].'|'.$config['secret']);

$href = 'href';

$params = array(
        'href' => $href,
        'template' => $message,
    );


$facebook->api('/' . $user . '/notifications/', 'POST', $params);

?>
Run Code Online (Sandbox Code Playgroud)

编辑2:在一个愚蠢的逻辑错误后它现在工作:)

小智 7

要发送通知,您必须使用应用程序访问令牌 - appid|appsecret因此您应该将其发送到服务器端并通过AJAX调用执行.PHP示例:

require_once("facebook.php");

$config = array();
$config['appId'] = 'YOUR_APP_ID';
$config['secret'] = 'YOUR_APP_SECRET';

$facebook = new Facebook($config);
$facebook->setAccessToken($config['appId'].'|'.$config['secret']);

$user = 'userid';
$message = 'message';
$href = 'href';

$params = array(
        'href' => $href,
        'template' => $message,
    );

$facebook->api('/' . $user . '/notifications/', 'post', $params);
Run Code Online (Sandbox Code Playgroud)

https://developers.facebook.com/docs/concepts/notifications/