Send facebook notification after invitation request

fb_logo Sometimes people ask me how to send notification in facebook app after invitation request processed.

This is a very easy solutions. You just need to carefully look the api request and return value. Then you can easily integrate the solution

Here I’m describing what is invitation, what is request and how to send notification after invitation/request successfully processed.

Update 23-04-2010
Facebook closed notification system from application. So sending notification part of this article is now obsolete .

There are many viral features in facebook platform, by using those you can easily inform others about your application. Here I mention 2 of these

  1. notification
  2. invitation

So what is invitation?
Look at these figures:


when some one send you any page/application/group invitation or request you’ll see like this figure at the right+top in your facebook homepage.

In application level, how will you integrate this?
According to

if you use this code

<div style="padding: 10px;">
  <fb:request-form method="post" action="index.php" content="hey" type="sample" invite="true">
    <div class="clearfix" style="padding-bottom: 10px;">
      <fb:multi-friend-selector condensed="true" selected_rows="0" style="width: 200px;" />
    <fb:request-form-submit />

you’ll see the following component in your facebook canvas page:


So users can easily send invitation/request to their  friends using this widget in your facebook app.

According to if you use this code

      <fb:request-form action="" method="POST" invite="true" type="appname" content="body of the message">
      <fb:multi-friend-selector showborder="false" rows="5"  exclude_ids="" actiontext="Invite your friends to use this app">

you’ll see the following widget in your facebook canvas page:


So using this widget users can easily send invitation/request to their friends about your app. So what happen when someone send invitation/request using any of these 2 widgets?

The friends who will get invitation/request will see  in their home page like below:home_page_invitation

There will no notification will trigger for invitation/request.
So what is notification?

Notification is like this:


Now if you want when user will send invitation/request the receiver user will also get notification then how will you implement that?

If you read this 2 pages carefully: or you’ll see:

POST Variables

Required Name Type Description
ids array An array of the user IDs chosen by the user.

What does it mean?

It means, if invitation/request processed successfully facebook will send a variable ids that means receiver friends uids (comma separated list).

So now, if you want after invitation/request processed you’ll additionally send notifications to those users who are invited/requested you can code like this:

<?php if(!empty($_REQUEST['ids'])) {
        echo "Your invitation processed successfully!";

        include_once "facebook.php";
        include_once "config.php";

        $uids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : "";

             if (!empty($uids))
                    $facebook->api_client->notifications_send($uids, 'some info', 'user_to_user');
        catch(Exception $o){
   } else { ?>
      <fb:request-form action="" method="POST" invite="true" type="appname" content="body of the message">
      <fb:multi-friend-selector showborder="false" rows="5"  exclude_ids="" actiontext="Invite your friends to use this app">
   <?php } ?>

For more info regarding notifications:

So, the logic is, after processed invitation/request you’ll get user ids, and you’ll send notification to those ids.

Have fun! 🙂

mahmud ahsan

Computer programmer and hobbyist photographer from Bangladesh, lives in Malaysia. My [Business | Twitter | Linkedin | Instagram | Flickr | 500px]

You may also like


  • Tonu
    September 26, 2009 at 9:26 pm

    WOW! lots of practical fb examples. Sure it will be helpful for FBians.:D
    Awesome post. 😀

  • GirijaSankar
    October 21, 2009 at 10:33 pm

    Hi friends if you need any zend mock test go here

  • Raj Mohan
    November 19, 2009 at 10:28 pm

    WoW.. This is very helpful. thanks man.

    I have some question can you pls clarify me pls.

    I have a code where I can send request to my friends.

    <fb:request-form method="GET" action="application urll" content="My Testing" type="App name" invite="false" content="Hi to all

    Using the above code I can able to send request to my friends. Now,

    I am having my application user ids in array. Instead of showing my friends inside request form, I want to show my application users. So I can select any one of them from the list and send request to them.

    Pls let me know how to do that.

  • Nikesh
    March 7, 2010 at 11:56 pm

    Its a gr8 job but its not working fro new api. Will u please check and modify it.

    • mahmud ahsan
      mahmud ahsan
      March 8, 2010 at 1:09 am

      @Nikesh, currently facebook ban sending notifications from application. So this tutorial will not work now.

  • Facebook Applications
    March 8, 2010 at 6:38 pm

    Now facebook has remove this notifications for applications so i think there is no problem in future for notifications.

  • nikesh
    March 8, 2010 at 6:54 pm

    Is any other solution you have.

    • mahmud ahsan
      mahmud ahsan
      March 9, 2010 at 11:16 am

      @Nikesh, yeah you can now send Email from your facebook application. But before that you have to set email domain in the application setting and you have to prompt extended permission to the user, if he accepts then you can mail him.

  • Raj Mohan
    March 17, 2010 at 12:23 am

    @Mahmud, thanks.. if you dont mind will you provide a sample code.. so that we can utilize in our application…

  • mahmud ahsan
    mahmud ahsan
    March 17, 2010 at 1:40 am

    @Raj, forget the things now. Because sending notifications from application is now deprecated in facebook. You can send email instead of notification if you want. You can check the following post for better understanding.

  • Kumaran
    April 7, 2010 at 7:34 pm

    Hi Mahmud,

    How to send the “Requests” using facebook apps for my friend ids…Please guide…Thanks

    Best Regards,

  • mahmud ahsan
    mahmud ahsan
    April 7, 2010 at 8:08 pm

    @Kumaran, in this article you’ll see the code to send request from your application to your friends. Just remove

                 if (!empty($uids))
                        $facebook->api_client->notifications_send($uids, 'some info', 'user_to_user');
            catch(Exception $o){

    this part from my example.


  • kumaran
    April 8, 2010 at 4:59 pm

    Hi Mahmud,

    Thank you for your reply. Facebook now blocked the below function

    $facebook->api_client->notifications_send($uids, 'some info', 'user_to_user');

    What, I need this type of notification or request to our friends. Please guide some alternative solution. Thanks

    Best Regards,

  • mahmud ahsan
    mahmud ahsan
    April 8, 2010 at 5:29 pm

    @Kumaran, yeah facebook blocked notification feature for application. As alternative you can request user to give his email address and you can send email to him instead of notification. Checkout this article

  • kumaran
    April 9, 2010 at 7:41 pm

    Hi Mahmud ahsan,

    How to set multi-select functionality in iframe method.. FBML its working fine… Thanks

    Best Regards,

  • mahmud ahsan
    mahmud ahsan
    April 10, 2010 at 12:11 am

    you’ve to use server fbml please check this link
    The fb:serverFbml tag is a very powerful tag for Facebook Connect sites and iframe applications. You use this tag to render FBML tags that otherwise cannot be rendered as XFBML tags (that is, any tags other than the ones that appear in the list above). Typical FBML tags you would wrap within fb:serverFbml are those that require user input, like fb:request-form. The contents of fb:serverFbml are rendered in a Facebook iframe.

  • kumaran
    April 12, 2010 at 9:11 pm

    Thanks mahmud,

    How to use javascript in facebook apps…Can you guide me…Please advice…

    I am awaiting for your reply.

  • mahmud ahsan
    mahmud ahsan
    April 12, 2010 at 10:42 pm

    There are 2 types of javascript for facebook application. One is and another is Facebook Javascript Library

    If you want to develop canvas base application you have to use FBJS. Its little modified version of normal javascript. So it would be easy for you to learn if you know javascript.

    If you want to develop FBConnect base application, then you could use normal javascript and also javascript framework like JQuery. And Facebook now provide javascript api library using this you can call facebook api directly from javascript.

  • kumaran
    April 13, 2010 at 4:28 pm

    Thank you Mahmud….

  • kumaran
    April 13, 2010 at 4:31 pm

    I need one more clarification…I need implement Image coverflow gallery integrate in facebook apps. Please confirm…..

    1. Which one is better FBML or Iframe?

    2. Coverflow gallery working in javascript. I will change entirely optimize in code in FBJS. Please advice….

    I am awaiting for you quick reply. Thanks

    Best Regards,

  • mahmud ahsan
    mahmud ahsan
    April 13, 2010 at 5:44 pm

    @Kumaran, it actually depends on you. If you want to use javascript framework like jquery then you’ve to chose iframe. Otherwise you can use fbml canvas.

  • Noirita
    April 23, 2010 at 12:36 pm


    Thanks for this wonderful article.
    Can you tell me whether i can send message to users after sending application request/invitation.

  • mahmud ahsan
    mahmud ahsan
    April 23, 2010 at 12:55 pm

    Update 23-04-2010
    Facebook closed notification system from application. So sending notification part of this article is now obsolete . You can only send email if user provide you email address, you have to ask to get email address from user by calling extended permission.

  • Chris
    May 17, 2010 at 9:41 pm

    Hi Mahmud,
    In the facebook api wiki, it says that, facebook currently use dashboard.addNews instead of send notification.
    Is it alternative solution for this?
    What is the different between these two?
    Also could you show us an example of how to use addnews funtion?
    Please advise.

  • mahmud ahsan
    mahmud ahsan
    May 18, 2010 at 1:33 am

    @Chris, Facebook changing their structure so quickly that if I write a article that become backdated after some months. 🙁 Notification from application is closed. You can now only use invitation system and email system and dashboard. Using graph api dashboard working example is different, I yet not write article on it. But you can check this article

  • Newton Curzi
    June 9, 2010 at 12:48 am

    Im happy I located this blog page, I couldnt obtain any information on this matter before. I also run a niche site and if you want to ever interested in a little bit of guest writing for me if possible feel free to let me know, im always look for people to check out my blog page. Please stop by and leave a comment sometime!

  • gopal
    October 30, 2010 at 4:47 am

    Hello mahmud ahsan…

    Your articles are awesome and pretty useful for us. I am able to find answers in your articles which I don’t find even in facebook forum or documentation.

    Coming to my problem,

    I have a requirement to send “application add request” like a “friend request”.

    Actually I have facebook userid (email id). Can I send application add request if I have facebook user id. Which means, instead of user intentionally add it, I need to send application add request to user so that it will appear in notifications tab on the home page

    I would be thank ful to you if you can give me idea about this.


    • mahmud ahsan
      mahmud ahsan
      October 30, 2010 at 12:44 pm

      No you can’t automatically send request on behalf of users.

      • gopal
        November 1, 2010 at 8:32 am

        Thank you mahmud for replying me.

        Its not onbehalf of user, but exactly speaking, the requirement is like below:

        Step1: We will save the facebook Email of the user(it is E-mail id of the user) at the registration time.

        Step2: As we have facebook Email id of the user, we want to send a application add request (like a friend request)

        Is this the same thing you are saying that it is not possible ?

        Thanks Mahmud….

  • Developer
    December 21, 2010 at 12:48 pm

    This is Bull***t now in the new Fb!!

  • webbalaji
    February 5, 2011 at 7:41 pm


    You posts shows your expertise in FB Programming. Ofcouse I have issue. Am a newbee to Facebook Programming, How do we get list of users accepted the application invitation. Please help me.

    • mahmud ahsan
      mahmud ahsan
      February 5, 2011 at 10:23 pm

      I can tell you the logic, after invitation you’ll get the invited friends ids, so save them in database, and in the invitation link provide a special parameter so when user first install the application you can track he comes from invitation.

  • Patricia
    June 11, 2011 at 12:14 pm

    Please, please, please kindly tell me is this no longer working in the new version of FBML?

    I was testing some new code for a new client. I deleted the old code that clearly showed my share button (and didn’t save it to a notepad). All I did was take out the part that refers to fbml version 1.1 and now I can’t see anything on the page at all. Even when I put back the reference to fbml 1.1.

    Even in Facebook’s help they refer to this stuff as legacy and seems to offer no further assistance on it at all.

    I’d greatly appreciate a response but won’t die if I don’t get one. Certainly not life or death situation, just sucks that it worked before my tweaking and now I’ve got nothing.

    • mahmud ahsan
      mahmud ahsan
      June 12, 2011 at 10:19 am

      yeap notification send from application is no longer exits.

  • david
    July 9, 2011 at 2:03 am

    this is the new way to send requests, I think you should update the post since it’s well ranked on google

    • mahmud ahsan
      mahmud ahsan
      July 9, 2011 at 11:08 pm

      I had a new post regarding that. You’ll see that in my homepage.

  • Anish K S
    September 5, 2011 at 4:07 pm

    I wanna send a notification to all of our application, Is any Api call available now?
    Previously it had done by REST API.
    Could Anybody help me?

    • mahmud ahsan
      mahmud ahsan
      September 5, 2011 at 5:05 pm

      You can’t send notification using api now. If you implement request and if your user request other user then automatically a notification will send.

  • Anish K S
    September 19, 2011 at 4:45 pm

    $app_id = YOUR_APP_ID;
    $app_secret = YOUR_APP_SECRET;

    $token_url = “” .
    “client_id=” . $app_id .
    “&client_secret=” . $app_secret .

    $app_access_token = file_get_contents($token_url);

    $user_id = THE_CURRENT_USER_ID;

    $apprequest_url =”” .
    $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);

    In this, I’m getting these kind of error….

    Warning: file_get_contents( [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /home/content/64/7405364/html/testapp/apprequest.php on line 19

    Warning: file_get_contents('INSERT_UT8_STRING_MSG'&data='INSERT_STRING_DATA'&&method=post) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /home/content/64/7405364/html/testapp/apprequest.php on line 29

    Please help me….

  • Gustavo VerayAragón
    November 5, 2011 at 6:36 am

    Gentlemen Facebook. Please request the lifting of that I applied for 30 days to add friends to invite strangers. In no time I invited a stranger at least 50 people we had mutual friends. Also I do not like doing this, I did not even have already been blocked several times. Just invite acquaintances, colleagues, relatives, family friends, etc.. From already thank you very much.

  • soul_killer
    November 8, 2011 at 12:48 pm

    Is it possible if i want to retrieve the IDs of all the friends(2nd level friends) that belong to my friends?

    Im trying to send a friend request from my application to friends of my application friends..

    Please guide..

  • Kizi 8
    June 22, 2013 at 5:15 pm

    My coder is trying to persuade me to move to .
    net from PHP. I have always disliked the idea because of
    the expenses. But he’s tryiong none the less. I’ve been using Movable-type on several websites for about a year and am anxious
    about switching to another platform. I have
    heard excellent things about Is there a
    way I can import all my wordpress content into it? Any help would be greatly appreciated!

  • beauty therapy training courses uk
    September 15, 2013 at 8:48 pm

    Aw, this was a very good post. Finding the time and actual effort to create a good article… but what
    can I say… I put things off a whole lot and never manage to get nearly anything done.

    October 6, 2013 at 12:58 pm

    My developer is trying to persuade me to move to .net from
    PHP. I have always disliked the idea because of the costs.

    But he’s tryiong none the less. I’ve been using WordPress on several websites for about a year and am anxious about switching to another
    platform. I have heard very good things about
    Is there a way I can transfer all my wordpress content into it?
    Any help would be really appreciated!

    October 8, 2013 at 4:28 am

    It’s the best time to make some plans for the future
    and it’s time to be happy. I’ve read this post and if
    I could I desire to suggest you few interesting things or suggestions.
    Maybe you can write next articles referring to this article.

    I want to read more things about it!

  • Andrew
    November 2, 2013 at 10:17 am

    Howdy would you mind stating which blog platform you’re working with?
    I’m planning to start my own blog in the near future but I’m having a difficult
    time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and I’m
    looking for something completely unique. P.S Apologies for getting off-topic
    but I had to ask!