Sending “App Requests” to multiple recipients using Graph API

只谈情不闲聊 提交于 2019-12-13 15:21:51

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/7919218/sending-app-requests-to-multiple-recipients-using-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!