Here is what I'm seeing in the docs:
Apps can send notifications to any existing user that has authorized the app. No special or extended permission is required.
Okay, sounds good. I'm using the JS SDK and here is what I'm trying to do:
FB.api('/me/notifications?access_token=' + window.accessToken + '&href=test&template=test', function(response) {
console.log(response);
});
This is what I'm getting:
"(#200) The "manage_notifications" permission is required in order to query the user's notifications."
I have tried replacing the href parameter with my app's real domain. Using my facebook ID instead of "/me/" makes no difference either. HELP!
I HAVE tried adding the manage_notifications permission (and still doesn't work...), but my question is why does it say the opposite in the docs?
EDIT: Went to 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);
?>
EDIT 2: After a silly logic mistake it now works :)
To send a notification you must use application access token - appid|appsecret
, so you should send it server side and execute via AJAX call. PHP example:
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);
https://developers.facebook.com/docs/concepts/notifications/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With