Post Message to User Wall from Your Facebook App

Your Facebook app can post message to the user’s wall by using some methods. Let’s see some of the easy methods.

Feed Dialog

The following simple example shows the most basic codes to display a Feed Dialog within a canvas page of a Facebook App:

<?php 

         $app_id = "YOUR_APP_ID";

         $canvas_page = "YOUR_CANVAS_PAGE_URL";

         $message = "Hi! I am testing my new Facebook Apps.";

         $feed_url = "http://www.facebook.com/dialog/feed?app_id="
                . $app_id . "&redirect_uri=" . urlencode($canvas_page)
                . "&message=" . $message;

         if (empty($_REQUEST["post_id"])) {
            echo("<script> top.location.href='" . $feed_url . "'</script>");
         } else {
            echo ("Feed Post Id: " . $_REQUEST["post_id"]);
         }
?>

Note:
Replacing the YOUR_APP_ID and YOUR_CANVAS_PAGE with the correct values found in the Developer App.

When user click on the Feed Dialog link on the Canvas page, the following screen will appear:

The user write something on the text field, for example:

After the user click on the Share button, the message will appear on the user wall, as shown in the diagram below:

If you wish a more interesting and personal Feed Dialog, you can add more parameters to the codes, for example:

<?php 

         $app_id = "YOUR_APP_ID";

         $canvas_page = "YOUR_CANVAS_PAGE";

         $message = "Hi! I am testing my new Facebook Apps.";

         // Additional parameters
         $link    = "http://www.mygreatname.com";
         $picture = "picture=http://www.mygreatname.com/images/server.gif";
         $name    = "MyGreatname Affordable Web Hosting";
         $caption = "One dollar for the first year";
         $description = "First come first serve basic";

         $feed_url = "http://www.facebook.com/dialog/feed?app_id="
                . $app_id . "&link=" . $link . "&picture=" . $picture . "&name=" . $name . "&caption=" . $caption . "&description=" . $description . "&redirect_uri=" . urlencode($canvas_page)
                . "&message=" . $message;

         if (empty($_REQUEST["post_id"])) {
            echo("<script> top.location.href='" . $feed_url . "'</script>");
         } else {
            echo ("Feed Post Id: " . $_REQUEST["post_id"]);
         }
?>

A more interesting Feed Dialog will be shown as below:

Direct URL

A more simple method is using a direct URL, as shown in the example below:

https://www.facebook.com/dialog/feed?
app_id=YOUR_APP_ID&
link=http://www.mygreatname.com&
picture=http://www.mygreatname.com/images/server.gif&
name=MyGreatname Affordable Web Hosting&
caption=One dollar for the first year&
description=First come first serve basic&
redirect_uri=YOUR_CANVAS_PAGE

Note:
Replacing the YOUR_APP_ID and YOUR_CANVAS_PAGE with the correct values found in the Developer App.

When user click on the above link , the following dialog box will appear (Note: the dialog box cannot be shown within Canvas):

Write some message on the text field, for example:

After the user click on the Share button, the message will appear on the user wall, as shown in the diagram below:

This way, users can post message to their wall from your Facebook App.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>