How to Send Mass Facebook Notification in PHP

How to Send Mass Facebook Notification in PHP thumbnail
Send Mass Facebook Notifications via FQL in PHP.

Facebook Query Language (FQL) allows you to use a SQL-style interface to query the data provided by the Graph API. Notification is the one of the tables of Facebook users. You can query this table to get the notifications for the current session user. The User object in Facebook has an equivalent notifications connection. Using the notifications table, you can send mass Facebook notifications via PHP code. The notifications table include columns such as notification_id, sender_id, recipient_id, created_time and updated_time.

Things You'll Need

  • PHP
Show More

Instructions

    • 1

      Open a Notepad and enter the following code:
      <?php
      /* PHP Facebook notification application */
      ?>
      Save the code as massmessage.php.

    • 2

      Define the Notification class as follows:
      Class Notification {
      Private $facebook;
      Private $fbConfig=array (
      ‘api_key=> ‘’,
      ‘secret_key’=>’’
      ); }
      This above code also defines the Facebook configuration settings.

    • 3

      Specify variables via code:
      Private $mailmessage=’’;
      Private $mailsubject=’’;
      Private $notification=’’;

    • 4

      Initialize the variables in function “init”:
      $this->mailmessage=”HTML Message”;
      $this->mailsubject=”Email”;
      $this->notification=”Check it out”;

    • 5

      Construct the facebook.php file:
      Include “facebook.php”;
      $this->facebook= new Facebook ($this->fbConfig['api_key'], $this->fbConfig['secret_key']
      $this->init();

    • 6

      Send notification via the following function:
      $this->facebook->api_client->notifications_send($ids, $this->notificationMessage, $this->notificationType);

    • 7

      Send mass notifications:
      $notifObj = new Notification ();
      $notifObj->sendNotification('137373777,39344939');
      137373777 is one of the user_id. You can add, at most, 100 users at one time in the “SendNotification” function.

Related Searches:

References

  • Photo Credit Stockbyte/Stockbyte/Getty Images

Comments

Related Ads

Featured