I own a couple of pages against Child abuse and now I'm developing a Facebook application for fighting against Child Abuse.

I'm somewhat a newbie, and I found many wonderful resources on the net, however, I don't seem to find what I really want.

I know to build a basic app that accesses a user's basic information(using fb_sig_user). However, I need the code to publish static content to my users' wall, request permissions for the same, (would be nice if it publishes each time they interact with my page).

It would also be nice if the app can post to the user's friends too..but its not a must.

Can someone help me? I have these files with me (its an FBML app,btw) and I'm stuck :


 if (isset($_REQUEST['name'])){
$uidc2 = $_REQUEST['fb_sig_user'];
echo $uidc2;


<div id="update"></div>
<form action="" id="frm_test" method="post" onsubmit="return false;">
 <input type="hidden" name="name" size="50" />
 <input name="name" type="button" clickrewriteurl='http://somewebsite.com/fb/tab.php' clickrewriteform='frm_test' clickrewriteid='update' value="submit"/>



require 'facebook.php';

$app_id = 'xyzzy';
$application_secret = 'abc';

$facebook = new Facebook(array(
  'appId'  => $app_id,
  'secret' => $application_secret,
  'cookie' => true, // enable optional cookie support

if ($facebook->getSession()) {
  echo '<a href="' . $facebook->getLogoutUrl() . '">Logout</a>';
  $user = $facebook->getUser();
} else {
  echo '<a href="' . $facebook->getLoginUrl() . '">Login</a>';


Any help a this point is really much appreciated. Thank you.


Curiousity rather than technical: what's the app going to do? A viral petition, email my congressman?

Written by Rup

yes, its more of a viral petition...like a simple msg such as "Stop child abuse" or something

Written by imaginonic

Accepted Answer

You can use the stream.publish method to publish stream to users of your app. If you want to post to users' wall even if they are not logged in, you need to ask them for the publish_stream extended permission first.


Getting Permissions

To get permissions, have a look at:


In your main config or header file , put code like this:

$facebook = new Facebook($appapikey, $appsecret);
$user = $facebook->require_login();

client_id=[YOUR APP ID]&
redirect_uri=[YOUR APP URL]&
scope=publish_stream, offline_access');

Replace [YOUR APP ID] with application id that you can see from application settings where you created the site in Facebook Developers section. Also replace the [YOUR APP URL] with your app url.

To Publish Steam

There is another javascript sdk method named FB.ui. Using the code you can prompt user for stream publish or share your page. Checkout streamPublish() and share() methods defination in my demo’s source code .

Have a look at this tutorial for more info:

Or You can use this function to publish the steam:

function publish() {

    var attachment = {
        'name': 'App Name',
        'href': 'http://apps.facebook.com/someapp/', 'caption': '{*actor*} perfomed an action!!',
        'description': 'The description goes here',
        "media": [{ "type": "image", "src": "http://www.example.net/images/logo.png", "href": "http://apps.facebook.com/someapp/"}]

    var action_links = [{ 'text': 'World Winner 2010', 'href': 'http://apps.facebook.com/world_winner/'}];

    Facebook.streamPublish('', attachment, action_links);

Change the settings in above function as per your requirements and call it like this when you need to publish the stream:


More Resources:

And you can find good facebook-related tutorials at this site:

Written by Sarfraz
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki