Search code examples
phpfacebookfacebook-graph-apinotificationsfacebook-group

Is it possible to send notifications for all members of a group in a single request?


I'm developing an application for Facebook where we use the Facebook Groups to connect the users. When a event occurs I send a notification to all members of that group (where the event happened).

After a little study of how to send a notification to a user using the Facebook framework for PHP I wrote this method:

public function sendNotification($user, $text, $href){
    $data = array(
        'href' => $href,
            'access_token' => $this->appAccessToken,
            'template' => $text
    );

    $notification = $this->fb->api("/$user/notifications", 'POST', $data);
}

Note that this code will send a notification for one user at a time, so I need to send N notifications, one for each member of that group in particular.

Is there any way to send notifications in a single request to be delivered to all members of a group (specified by its ID)?


Solution

  • No, a Graph API POST request reaches only one user:

    POST /{only_one_user_id}/notifications?access_token= … &template= … &href= …
    

    You have to loop on each member of the group.