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;
 }

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.


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.


1:\ Go to developer.facebook.com

2:\ Go to your app Settings \ Basic

3:\ Add new platform from plus at button bottom of the page

4:\ Choose Facebook Canvas

now you may need to fill form with your url

That's it


Need Your Help

regex for accepting only persian characters

c# asp.net regex unicode

I'm working on a form which one of it's custom validator should only accept persian characters...I used the following code:

How to handle Play Framework 2 database evolutions in production

java postgresql playframework playframework-2.0 playframework-evolutions

It seems that whenever I change my models, Play Framework asks me to run a script that deletes my entire schema and recreates it. Obviously this won't work for production, so what is the proper wa...