Publish on Facebook Fan Page as fan user Using PHP

First Follow all the steps to give permissions to publish on Facebook.

Add FaceBook application to your fan page

Just Go to

Find link ‘Add to my Page’ on the left, click on it. Find your page on the list and click on ‘Add to page’ next to this page.

Set Your Application type as WEB

Go to

Choose ‘Web’ next to ‘Application type’ and click on ‘Save Changes’ button.

Add permissions to your app

Prepare special link:,offline_access&enable_profile_selector=1&profile_selector_ids=ID_OF_YOUR_PAGE

replace YOUR_API_KEY for an API KEY of your application and ID_OF_YOUR_PAGE for an id of your page

Run this URL in your web browser. Click on ‘Allow’. This will set the permissions to your application to publish on page.

You should see a message: ‘Success’ message.

Check Permissions

Go to and check your permissions.

Choose your application, change ‘Response Format’ to JSON, choose method ‘users.hasAppPermission’, fill publish_stream in ext_perm and id of your page in uid.

You should see result: 1.

That means that everything is ok. If the result is 0. then something went wrong.  Then check all the above steps again.

Code To Publish on Fan Page as Fan User Using PHP

Then to publish on fan page as a Fan page user and not the facebook user just follow below code.

For this you need to get Fan page ID:

Example :

where xxxxxxx is the fan page id.

In Steam publish method just replace the $page_id with your above fan page id.

stream_publish($message, $attachment,$action_links, null,$page_id).


// FB_APIKEY is your facebook application api key
// FB_SECRET is your application secrete key

define('FB_SESSION', 'YOUR_SESSION_key');


try {
 $facebook = new Facebook(FB_APIKEY, FB_SECRET);
$facebook->api_client->session_key = FB_SESSION;
 $fetch = array('friends' =>
 array('pattern' => '.*',
 'query' => "select uid2 from friend where uid1={$user}"));

echo $facebook->api_client->admin_setAppProperties(array('preload_fql' => json_encode($fetch))); 

$message = 'From My App: publish steven on facebook Fan Page as Fan User';
$page_id ="xxxxxxxxxxx";
if( $facebook->api_client->stream_publish($message, $attachment,$action_links, null,$page_id))
 echo "Added on FB Wall on Fan Page";
} catch(Exception $e) {
 echo $e . "<br />";


Below is the screen where you can see the message published are fan user.
Publish on facebook fan page as fan user

— Steven
Follow Us

Steven Fan Page on Facebook