Alaa Shaheen
Alaa Shaheen

Reputation: 51

Sending "App Requests" to multiple recipients using Graph API

I'm using Facebook's new Frictionless Requests, which allow you to send user-generated request to multiple pre-selected friends using the 'to' property in the FB.ui() method:

Fb.ui({
    method: 'apprequests', 
    message: '...', 
    to: 'uid1,uid2,uid3,...'
}, cb);

I'm wondering how I can similarly send an app-generated request to multiple recipients in a single API call. The Facebook Doc shows the following example for sending an app-generated request to a single recipient via Graph API:

<?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);
?>

However, Is there a way to send an app-generated request to multiple recipients via graph api?

I understand that what I'm trying to achieve can be done through batching, but I would like to know if there's a more practical way for sending an app-generated request to multiple recipients, equivalent to how FB.ui({'method', 'apprequests',...}) works?

Upvotes: 2

Views: 9187

Answers (1)

Jont
Jont

Reputation: 972

You can use the ids query parameter

eg. ids=userid1,userid2

$apprequest_url ="https://graph.facebook.com/" .
        "/apprequests?ids=USERID_1,USERID_2,USERID_3" .
        "&message='INSERT_UT8_STRING_MSG'" . 
        "&data='INSERT_STRING_DATA'&"  .   
        $app_access_token . "&method=post";

Upvotes: 5

Related Questions