DaTval
DaTval

Reputation: 326

Sending notification using application on Facebook

How can I send notification using application on Facebook? As I know this function FB blocked several monthes ago, but there are still some applications, which requests are notified me using FB notifications. So how can I make the same? In graph API there is nothing said about it.

Upvotes: 5

Views: 16827

Answers (2)

Ben
Ben

Reputation: 2651

There is a way of doing this, it is extremely hard to find in the documentation and it doesn't work very well (and I think it might even be slightly buggy).

http://developers.facebook.com/docs/channels/#requests

for some reason it is under the requests section rather than the notifications section.

Here is the code example on the page, I tested this and it doesn't result in a red notification icon appearing on the globe notification thing - it just increments the number on the application bookmark on the left hand side of your home page. I imagine this is an extremely inneffective way of getting a message to your users. If you have an app that is not a canvas app (like a page tab app) this actually does nothing as you don't have a bookmark icon for the application.

<?php 

  $app_id = YOUR_APP_ID;
  $app_secret = YOUR_APP_SECRET;

  $token_url = "https://graph.facebook.com/oauth/access_token?" .
    "client_id=" . $app_id .
    "&client_secret=" . $app_secret .
    "&grant_type=client_credentials";

  $app_access_token = file_get_contents($token_url);

  $user_id = THE_CURRENT_USER_ID;

  $apprequest_url ="https://graph.facebook.com/" .
    $user_id .
    "/apprequests?message='INSERT_UT8_STRING_MSG'" . 
    "&data='INSERT_STRING_DATA'&"  .   
    $app_access_token . "&method=post";

  $result = file_get_contents($apprequest_url);
  echo("App Request sent?: ". $result);
?>

Upvotes: 0

Brent Baisley
Brent Baisley

Reputation: 12721

The latest way to send "notifications" is through the Request 2.0 implementation. They are no longer referring to them as notifications. Facebook now decides if the user will get a notification in addition to a request or not.

http://developers.facebook.com/blog/post/464/

Upvotes: 3

Related Questions