Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't send FB Notifications with new API

Really need some help with this one!

I'm trying to send notifications from a canvas app using the new notifications API but I keep getting the following exception:

OAuthException: (#200) Only web canvas apps can send app notifications

However, the app IS loaded in the Facebook canvas -- I'm making an ajax call to my server when the user takes a particular action which triggers the notification POST request. The user has also authorized the app.

This is the code I'm using:

$graphUrl = $user_id . "/notifications";
$params = array( "access_token" => $admintoken,
             "href" => $link, 
         "template" => "string of text < 180 chars"
        );

try {
  $result = $facebook->_graph($graphUrl, 'POST', $params);
 } catch (Exception $e){
     echo $e;
 }
like image 884
Zak Khalique Avatar asked Nov 07 '12 04:11

Zak Khalique


People also ask

How do I fix Facebook notifications problem?

Go to Menu > Settings and scroll down to the list of installed apps. Tap on Facebook and then select Push Notifications. Toggle the slider next to Messages to enable it (it should be set to ON). Repeat this step for any other type of notification that you might want such as Friend Requests, Comments or Wall Posts.

How does Facebook implement notifications?

When someone like your posts, comments, send message, etc, facebook sends a notification as soon as the event done.

Is the Facebook API free?

In the newest version of the Graph API (v2. 9), we're announcing features that simplify development, making it even easier to build apps and experiences with Facebook. We're providing free access to over 140 million places around the world, the same data that powers Facebook, Instagram, and Messenger.

What is Jewel notification?

It simply means that the user clicked on a notification in the notification “jewel” (that's what FB call the thingie in the top navigation bar, where notifications are shown) to get to that address … It is just a tracking parameter. Follow this answer to receive notifications.


2 Answers

I just ran into this too and this is how I solved it, but this may not be relevant to you as you seem certain yours is a Canvas app. Mine is an app that mostly runs off Facebook, but has Facebook integration hooks that means users can authorise my Facebook App and then receive updates about interesting events via the Facebook framework.

I went to edit my App settings in the Facebook Developers app, look on the Settings->Basic page near the bottom. I only had "Website With Facebook Login" checked. I checked "App on Facebook" and this gave me a "Canvas Page" and various other settings. With these filled in and saved, the POST to uid/notifications worked immediately.

Incidentally, going to apps.facebook.com/myappnamehere fails because it redirects to https and the request to my site fails because my SSL isn't set up right, but this didn't prevent notifications being sent under that apps credentials.

like image 128
Neek Avatar answered Oct 18 '22 18:10

Neek


Recently, I was facing this same issue and I found that Facebook Web Games are formally known as Facebook Canvas.

So, Just create an Facebook game configuration under Settings->Basic page (You will see add button at the bottom of this page) and your API will start sending notifications.

like image 25
Ashwani Kumar Avatar answered Oct 18 '22 18:10

Ashwani Kumar