Publish facebook page status or wall post automatically

fb_logoFacebook page is now very popular. Many companies and people create facebook page for their own publicity. Suppose your company has 100 products and they want to maintain 100 facebook pages, then isn’t it very difficult to update status all of the pages manually?

In this article, I’ll show and discuss about 2 facebook api, using that you can easily update your facebook page status or publish wall post on that page automatically

I assume that you know how to set cron from hosting admin panel, I also assume that you have intermediate knowledge of facebook application development and their api usage.


At first you’ve to setup a new facebook application. In the application setting look Authentication and in the Authentication setting must tick Facebook Pages


Now save the api and secret key either in your database or config file.

Update Status or Publish in Wall of your facebook page:

To update status of a facebook page, you must have to become an admin of that page. Now add the newly created application on that facebook page.

To add application in your facebook page: visit where XXXXXXXX is the id of your newly created application. Now click Add to my page


This will show you a list of pages. If you don’t see your desire facebook page, remember either you don’t an admin of that page or you already added this app on that page.

To update page status, you need extended permission. Write a php script for your facebook application and run that script inside facebook. Like

//filename: permission.php
<script type="text/javascript">
    function addFbAutostatus(id){
        Facebook.showPermissionDialog('status_update', null, true, [id]);
    function addFbAutoWallPostPublish(id){
        Facebook.showPermissionDialog('publish_stream,offline_access', null, true, [id]);

<a href="#" onclick="addFbAutostatus('XXXXXXXXXXXx'); return false;">Page Status Update</a> //replace XXXXXXXX by your facebook page id

<a href="#" onclick="addFbAutoWallPostPublish('XXXXXXXXXXXx'); return false;">Page Wall Update</a> //replace XXXXXXXX by your facebook page id

In the canvas page, you’ll see the link Page Status Update, click it and accept the permission if you only update status. If you want to publish photos/videos on page wall then you’ve to click Page Wall Update and to accept those permissions.

Now write a script that will update your facebook page status or publish wall post:

//filename: cron.php
include_once "config.php";
$facebook   =   new Facebook($config['api_key'], $config['secret_key']);

$status      =   "Sample Status";
$pageid      =   XXXXXXXXX; //replace it by your desire facebook page id
try {
	$status = $facebook->api_client->users_setStatus($status, $pageid);
catch(Exception $o ){

/*if you want to publish wall post in facebook page, then you have to use another method and remember for this method call you've set your user id and session key, here i just shown how to publish status using stream_publish method, but you can also publish video, image as wall post using stream_publish method
$user = your user id and $session_key = your facebook session key, you can obtain them by
$user = $_REQUEST['fb_sig_user'];
$session_key = $_REQUEST['fb_sig_session_key'];
And don't forget to save them in database, because you'll need them when you will use cron.php from offline
try {
      $facebook->set_user($user, $session_key);
      $facebook->api_client->stream_publish($status, null, null,  $item['pageid']);
catch(Exception $o ){

Now run in browser:

And check the page, you’ll see you facebook page’s status updated. :) If you want to predefine many statuses and update them automatically, then create an admin panel and database from where you’ll add many statuses, and make the cron.php more dynamic and set it as cron. So that cron.php catch statuses one by one from database and based on publish-date it will update your facebook page by updated status.

To learn more about stream_publish method: Click Here
To learn more about users_setStatus: Click Here

mahmud ahsan

Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

You may also like


  • kalyan
    January 21, 2010 at 7:10 pm

    hi mahmud ahsan,

    This is very good article u post, but message we posting to wall as a fan , but not admin.., so i can’t share messages with other fans, do u have any suggestions so that i can post as a Page not as fan.,

  • kalyan
    January 21, 2010 at 8:02 pm

    i mean to say that, what ever i am publishing is showing under “Just Fan” , but i want it show in “Just Page_name”., i used $user = userId, and $item[‘pageid’] = MyPage id..,

    I am new to PHP ..

  • mahmud ahsan
    Mahmud Ahsan
    January 21, 2010 at 9:07 pm

    @Kalyan, if you use users_setStatus this method then page update will occur as page admin. If you want to use stream_publish then click setting in page wall and set Default View for Wall: Posts by Page and Fans. Then all wall posts you will see in the same page.

  • kalyan
    January 22, 2010 at 2:40 pm

    thank you mahmud ahsan, for your response,
    While i am updating status update, I had occurred with following
    Updating status requires the extended permission status_update

    I know that is bcoz, that Need to have extended permission, i with URL,

    That is because, i dont understand how to use permission.php

  • mahmud ahsan
    Mahmud Ahsan
    January 22, 2010 at 2:55 pm

    @kalyan, you just need to prompt user for extended permission. If user granted it, then you don’t have to worry about how you could use it. Just call the api status_update and it will update your page status.

  • kalyan
    January 28, 2010 at 7:57 pm

    hi, Ahsan
    I am trying in different ways ways to publish on page wall, Let now i created new application & page.., by accessing permission.php nothing is done for me,

    can u say how to use permission.php.

    presently i occurred with following error, while doing status update.

    Updating status requires the extended permission status_update

    thank you for all you’r response.

  • buy r4 dsi
    January 29, 2010 at 6:26 pm

    This is a nice post.You have given very useful application that can easily update facebook page status or publish wall post on that page automatically..Thank you very much for giving such a good information.

  • David
    February 23, 2010 at 3:52 am

    well thanks, it’s pointing me in a better direction. but it’s a very vague article… and if you havent already been trying this for a while you’ll be totally lost.

  • Ry
    April 24, 2010 at 1:07 am

    Great article. I read like 5 before finding this one… and this one actually got it working for me! Thanks!

  • Roky
    April 29, 2010 at 7:59 pm

    Great article, but it didn’t worked for me, it always give me 201 or not enough permission. This link helped me:

  • kalyan
    May 3, 2010 at 10:04 am

    this is very good article for publishing to walls, Ahsan provided lot of information.

    if still you find any problem to publish run following URL,

    • To Grant permissions to Application to access your Wall, feeds,publish_stream&enable_profile_selector=1

  • Maged
    May 24, 2010 at 12:53 pm

    Hi Ahsen,

    I checked your code. The problem that I can not use publish_stream. Could you give us a clear example with publish_stream. Thank you very much

  • ccarrasco
    July 6, 2010 at 11:42 pm

    Hi Mahmud Ahsan how to publish offline with new graph api ?

    Thank you very much

  • Marco
    September 27, 2010 at 10:14 pm

    I know this post is a little bit old but I hope you can help me, im trying to post to my page and I did everything you said and im stuck at this error:

    Fatal error: Call to a member function users_setStatus() on a non-object in /home/.lukey/percepcion/ on line XX

    Thank you very much

    • mahmud ahsan
      mahmud ahsan
      September 28, 2010 at 4:10 pm

      Hi Marco, please update your php-sdk, the sdk i used in this post is old.

      The latest sdk code to update status

      if ($fbme){
              //update user's status using graph api
              if (isset($_REQUEST['status'])) {
                  try {
                      $status       = htmlentities($_REQUEST['status'], ENT_QUOTES);
                      $statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> $status, 'cb' => ''));
                  } catch (FacebookApiException $e) {
                  echo "Status Update Successfull. ";
      • Marco
        September 29, 2010 at 6:14 am

        Thank you very much for such a quick answer, one last question: If i want to post the update to a fan page instead of a fan page? do I have to use this:

        $statusUpdate = $facebook->api(‘/pageidxxx/feed’, ‘post’, array(‘message’=> $status, ‘cb’ => ”));

        I suppose that I have to be logged in as the admin of the page or I’m I mistaken?

        Thank you very much for the help you provide to all of us

  • Ryan
    September 30, 2010 at 2:38 am

    Hey Mahmud,

    Quick question – I am trying to place a comment on a post on a Fan Page for a business that I ‘like’. When I try to post the comment via the PHP sdk, I get ‘User not visible’ error. But I am able to ‘Like’ the same post via the API. This doesn’t make much sense.

    Any ideas why this happens? I am sending in the access token, post id, target id (fan page id), and the comment text to the API call.


  • Pratyus
    October 2, 2010 at 4:21 am

    Hi Mahmud,

    I refered to your blog to write a php script, that would post on the wall of my app page through a tunnel app. It was working fine till this monday. But now it fails to upload pictures. If it just a status update, it works fine though.

    Upload picture returns with a
    FacebookRestClientException Object
    [message:protected] => An unknown error occurred

    This is how I gave extended permission to my tunnel app (which can post on fan pages)

    call to upload picture:
    $facebook->api_client->photos_upload(dirname(__FILE__).”/”.$data[‘picture_1’], null, $data[‘caption_1’], $page_id);

    Code to update status:
    $facebook->api_client->users_setStatus($data[‘message’], $page_id);

    Are you aware of this?

    • shevy
      October 18, 2010 at 1:26 pm

      I;m getting the same exception message,
      Did you ever figure it out??

  • SD
    October 14, 2010 at 3:26 pm


    thanks for the tutorial.
    One question: Where do I get the config.php? It’s not included in the SDK and not in your tutorial.

    Thank you and sorry for my bad English :)

  • SD
    October 14, 2010 at 4:03 pm


    ok, now i found your answer to Marco’s question (September 27, 2010 at 10:14 pm) – i think thats it.

    But now i get this error: “Error validating application.”
    So i tried the first script in your tutorial again, that to authorisize the app, but there i get no popup (again)… could it be, that that script is old, too?

    sorry for my bad english again :S I hope you understand my text anyway

    • mahmud ahsan
      mahmud ahsan
      October 14, 2010 at 4:36 pm

      Please use facebook latest php SDK to publish post automatically.

      • SD
        October 14, 2010 at 5:05 pm

        I use that:
        Isnt that the lastest? :S

        • SD
          October 14, 2010 at 6:11 pm

          Update :)

          This: $statusUpdate = $facebook->api(‘/me/feed’, ‘post’, array(‘message’=> $status, ‘cb’ => ”));

          posts to my profile wall… but i want to post on my pages wall. whats the syntax for that?

          • Marco
            October 14, 2010 at 10:31 pm

            SD, first you need to add the “manage_pages” permission to your application. Once you have granted that permission, you can grab an access token for each page you manage :

            $page_id = “xxxxxxxxx”;

            foreach($accounts[‘data’] as $account)
            if($account[‘id’] == $page_id)
            $token = $account[‘access_token’];

            then you can post like this

            $status = $facebook->api(‘/’ .$page_id .’/feed’, ‘post’,
            ‘message’=>’your message’,
            ‘cb’ => ”,
            ‘access_token’ => $token,
            ‘picture’ => ‘funnyface.jpg’,
            ‘name’ => ‘text’,
            ‘caption’ => ”,
            ‘link’ => ‘link.php’,
            ‘description’ => ‘description’));

            echo “Status Update Successfull. “;

          • SD
            October 20, 2010 at 12:56 pm

            Hi Marco,

            thanks a lot for your help!

            One more question:

            Where do I get the “accounts”-Array for this foreach? :

            foreach($accounts[‘data’] as $account)
            if($account[‘id’] == $page_id)
            $token = $account[‘access_token’];

            Whitout the token I only can post to my pages wall via the user-account.
            Thank you :)

          • SD
            October 20, 2010 at 5:15 pm

            I got it :) :)

            Thanks to all for the help!

  • Sanjay
    October 15, 2010 at 11:21 am

    Hi, mahmud ahsan
    This is a very good article you have post and it’s quite helpful me.
    I have a one problem as i don’t have a much knowledge about FB api so can you please help me to complete my task. I am very thank full to you if you help me to solve my problem.
    Here is my problem.

    In database i have a multiple record with specific data and time at that date and time i want the update the status on facebook with new facebook api using php

  • Sanjay
    October 16, 2010 at 6:16 pm

    Hi, mahmud ahsan
    Please help me as soon as possible.
    thanks in advance

  • Sanjay
    October 28, 2010 at 5:58 pm

    thanks for your replay. As i told you i haven’t a much knowledge of FB API. If it is possible please give me a step by step solution (with new FB API).
    Actually i want same functionality you describe in your post i.e. publish wall post on page automatically using crone job.

    please give me a solution with new facebook api

    thanks in advance.

    • mahmud ahsan
      mahmud ahsan
      October 29, 2010 at 6:45 pm

      Sorry I’m very busy, even I couldn’t manage time to write a new post :S

      • Sanjay
        October 29, 2010 at 7:03 pm

        ok no problem. i have done almost my task.
        once again tanks for reply

  • Riaz Ali
    November 25, 2010 at 8:49 pm


    I want to publish on Facebook wall from a “Website”. I have heard that one can do that by using “Facebook Connect”. So can you please kindly tell whether there is a way to do so, and if there is, then please tell me how to do that. Please help me as soon as possible.


    • PHPWalkover
      November 26, 2010 at 11:07 pm

      Dear Riaz,

      I have solution to you. pls contact me to


  • Walkover
    November 26, 2010 at 11:05 pm

    Dear All,

    really its a great post. but i need to post my messages in my page’s wall. i can do this using the above example, but the posted by seems to be ‘logged in user’, is it possible to have posted by ‘page name’ . really this is urgent to me. anyone pls help.


    • mahmud ahsan
      mahmud ahsan
      November 27, 2010 at 8:36 pm

      Please checkout facebook’s new way to publish wall post to a page.

      • Walkover
        November 27, 2010 at 10:45 pm

        Dear Mahmud,

        Thanks for the reply. could you pls give more info with some sample or syntax to post the same.


        • mahmud ahsan
          mahmud ahsan
          November 30, 2010 at 11:55 am

          If you want to publish automatically, using php’s new sdk you’ve to store the access_token or $facebook’s session data in your database. Then using facebook api you can publish stream automatically. Please checkout my latest post ‘essential graph api’.

          • Walkover
            November 30, 2010 at 1:44 pm

            Dear mahmud ,

            Thanks for the information,. i have gone thru the page [ ]

            yes using the given code we can post message to PAGE’s wall. but my exact need is – the post should be posted by the same PAGE.

            but currently its posted by PAGE owner [logged in user]

            is it possible to post a message into a PAGE’s wall , posted by the same PAGE.

  • wasi
    January 3, 2011 at 4:04 pm

    hi all,
    i am new with facebook. I want to publish automatic on user wall on fan page,
    prescribed script is not working for me. i am facing this error. please help me.
    Fatal error: Call to undefined method Facebook::set_user() in /usr/www/users/onebon/theupsucker/welcome.php on line 225


  • Walkover
    January 3, 2011 at 4:11 pm

    hi Wasi,

    pls try the below here you can see a form [after facebook login], pls fill the form and click the submit button, that filled data will send to your wall. if you provide any page id, that data will send to the ‘page’s wall’

    pls try and let me know. you can contact me directly for more details

  • Kunal
    February 9, 2011 at 12:16 pm

    It again seems to be very useful post..but I am stuck here.
    I am able to post to a Facebook Page (I am the admin) but with my own name.

    What I want to know is I can make it automatic to publish a feed/post to Page wall everyday.


    • Kunal
      February 9, 2011 at 12:48 pm

      Also, please tell me how to get this:

      foreach($accounts[‘data’] as $account)



      • Walkover
        February 9, 2011 at 1:12 pm

        Hi Kunal,

        I have code for the same, actually am a freelancer, if you ready to spend few $, pls let me know. , i can provide the code to you…

    • Kunal
      February 9, 2011 at 3:35 pm


      I am done with the $accounts.
      I am able to make updates to Page which gets created with my Apps (a cron job).

      Now, I am trying to make update on a Page which I created and I am admin of. When I am logged in Facebook and make a Update it makes it from my name.
      As written above, we can do it from Page’s name by using a Token. So, for this page I am not able to update even after using Token and it shows error like:

      Fatal error: Uncaught OAuthException: (#200) The user hasn’t authorized the application to perform this action thrown in

      Please tell me what should be done. Are there some specific permissions that should be given to Apps for this Page?

      • Jarom
        March 4, 2011 at 12:32 pm

        If you want to enable offline posting you will want to do the following permissions to post to your page:


        The offline_access permission will make the authentication tokens not expire so you can perform the actions without having to logon as the user each time.

        The publish_stream permission is required to post the updates.

        The manage_pages allows your application to act on behalf of the user for page management tasks. You may be able to do it without this particular permission but I include it on my authorization requests just to be safe.

  • Walkover
    February 9, 2011 at 12:38 pm

    Hi Kunal,

    I have code for the same, actually am a freelancer, if you ready to spend few $, pls let me know. , i can provide the code to you…

  • Kapil Jain
    March 21, 2011 at 1:00 pm

    I found an article at describing publishing on walls for media using graph and javascript api

  • Mathias
    July 29, 2011 at 8:55 pm

    If you are looking for an alternative solution please check this post, it finally helped me out after reading a bunch of other tutorials.

  • f0X
    November 17, 2011 at 3:48 pm

    If I want post facebook comment to status wall in facebook fanpage. I can do that? Please help me

  • Photo Engraved Pendants
    January 10, 2012 at 11:56 pm

    Hello There. I found your weblog the use of msn. That is an extremely well written article. I’ll make sure to bookmark it and come back to read more of your useful info. Thank you for the post. I’ll definitely return.

  • web designer dubai
    June 21, 2012 at 10:46 pm

    helpful to new Facebook app developers…good work

Comments are closed here.

About Me

Hi I am Mahmud Ahsan. I Love computer programming and write occasional blog post. In my early career I worked mostly on web based application and since 2011, I exclusively working on iPhone and android applications. I work at home, father of a nice kid and husband of a beautiful wife. [My Business | Twitter | Linkedin]

Twitter Feed