Monday, April 11, 2011

How to post from facebook app to facebook page?

* NOTE :-

Please follow all the steps carefully and sequentially. Users are advised to follow every step in different tab.

For all the steps we are considering following options :-

1. FB Page :-
Name : Sample Page
{PAGE_ID} : 121364427524405

2. FB App :-
Name : Sample App
{APP_ID} : 303409109772222
{API_KEY} : 222223632fdc6ffffe4a53a453333333
{APP_SECRET} : 1111111111111115f3939c1513ee0844

3. {REDIRECT_URL} :- http:/

In order to post data from App page to other page we have to follow the following steps:-

synopsis :{APP_ID}&redirect_uri={REDIRECT_URL}&scope=email,read_stream,offline_access,manage_pages


Redirected to :-|W8_4DqYq_KCX_oBaa11oJJQ373Q

Output on redirect URL's screen :
[access_token] =} 303409109772222|60ad2f9f47cdaf5e03176824-100000098944650|xAOzhvZAJELuLgJVouW1l7nrMLQ

synopsis :{APP_ID}&redirect_uri={REDIRECT_URL}&client_secret={APP_SECRET}&code={CODE_GENERATED_IN_REDIRECT_TO_URL_IN_STEP_1}


Output on redirect URL's screen :
[access_token] =} 303409109772222|60ad2f9f47cdaf5e03176824-100000098944650|xAOzhvZAJELuLgJVouW1l7nrMLQ

synopsis :{APP_ID}&redirect_uri={REDIRECT_URL}&scope=email,read_stream&response_type=token


synopsis :{APP_ID}&client_secret={APP_SECRET}&grant_type=client_credentials


Output on redirect URL's screen :

synopsis :{APP_ID}&redirect_uri={REDIRECT_URL}&scope=manage_pages&response_type=token



* NOTE : This URL will yield the listing of all pages in JSON format. We will have to find out the ACCESS_TOKEN of that page, on which we have to post.


Output on redirect URL's screen :

{"data":[{"name":"Sample Page","category":"Media\/news\/publishing","id":"121364427524405","access_token":"303409109772222|60ad2f9f47cdaf5e03176824-100000098944650|121364427524405|LDf-47eJi-dYgjourPlz4Kp78Jg"}]}

In our case we have to post on Sample page - the first entry in our JSON string. So we will extract access_token parameter of this JSON string for future usage.

synposis :{API_KEY}&connect_display=popup&v=1.0&next={REDIRECT_URL}&cancel_url=,publish_stream,offline_access


Redirected to :-{%22session_key%22%3A%2260ad2f9f47cdaf5e03176824-100000098944650%22%2C%22uid%22%3A100000098944650%2C%22expires%22%3A0%2C%22secret%22%3A%227367a1a32dc7240e8b2fd50c48331c8a%22%2C%22sig%22%3A%22fcf7ce7683a13ffb83a4d96a2aa7f1cb%22}

curl -F 'access_token={ACCESS_TOKEN_GENERATED_FROM_STEP_6}' \
-F 'message={MESSAGE}' \
-F 'link={HYPER_LINK}' \
-F 'picture={IMAGE}' \
-F 'name={IMAGE_NAME}' \
-F 'caption={IMAGE_CAPTION}' \
-F 'description={DESCRIPTION}' \


curl -F 'access_token=303409109772222|60ad2f9f47cdaf5e03176824-100000098944650|121364427524405|LDf-47eJi-dYgjourPlz4Kp78Jg' \
-F 'message=Message \
-F 'link= \
-F 'picture=' \
-F 'name=Name \
-F 'caption=Caption \
-F 'description=Description \
-F 'actions={"name": "Caption1", "link": ""}' \

* Note: On success it will return JSON_ENCODED_STRING with post-id as id



  1. Hi,

    First of all thanks for writing it up and sharing with us.

    Now, I am a PHP dev new to Facebook API and integration so to use that I would need a little more info.

    It would be great and I suppose helpful for other readers if you could answer these questions:

    A) Is it so that the steps 1 to 7 need to be executed just once to allow anyone with access to the app to post on said wall forever?
    Or does it need to be repeated every time you want to publish from the same app to the same page?
    Or does it need to be executed once for each single FB user that will post from the app to the page?

    I tired to wrap it up in an automated PHP sequence to be executed every time someone needs to post from our app to our FB page but it won't work. Already in step 2, when it is executed the second time I get the "Error validating verification code" error.

    B) What is the lifetime of the {ACCESS_TOKEN_GENERATED_FROM_STEP_6}?

    Thanks in advance,

  2. Hi Jurek,

    In order to post from facebook app to facebook page, you need to follow the mentioned steps only once & sequentially.

    The access_token will persist life long.

    How you automated this? I mean you wrote a script for that?

  3. Hi Jatin,

    Thanks for your reply. Good to know one has to go through this process only once per combination of page-app. This is what I was hoping was the case, wasn't sure.

    Indeed, it was a PHP script that would sequentially run the first few steps, making facebook redirect to the next step, getting responses and passing tokens on.
    I might have made a mistake somewhere perhaps, I am going to give it another try.

    I also don't have much experience with PHP's lib-curl so not sure how to translate the curl command-line notation in your post to the PHP curl functions, but I am sure there are resources out there, I just need to find the right ones.

    Once again thanks for your help.

  4. Hey Jurek,

    Ya, I recommend you that you should follow these steps manually.

    And simply putting these curl commands in backticks i.e. `` will run these commands.

    In fact I did the same in my project.

  5. Thanks for the help, it seems to work now.

  6. how i can get the Output on redirect URL's ???

  7. I need to send notification to user from my app... wt to da???

  8. i am using server. what is the equalent to CURL in