user683680
user683680

Reputation: 79

facebook php sdk notifications

previously it was possible to send notifications from my app to user using method:

$facebook->api_client->notifications_send

But now it is depreciated, any ideas how i can send notifications using new SDK?

Upvotes: 1

Views: 3950

Answers (1)

jBit
jBit

Reputation: 2981

Take a look at requests: http://developers.facebook.com/docs/channels/#requests

Using the Graph API you can make a request with:

https://graph.facebook.com/USER_ID/apprequests?message='INSERT_UT8_STRING_MSG'&data='INSERT_STRING_DATA'&access_token=VALID_ACCESS_TOKEN&method=post

Example from above link:

<?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: 2

Related Questions