0

I have a webapplication with a cms-system. I have created a task that is executed when someone publish a newsarticle on the page. Simple thing. What I would like to do is to publish this newsarticle on our Facebook page AS the page.

There are a lot of old versions of api and stuff out there so I cannot figure out what is the most updated version of doing this.

Can someone please explain the steps I need to perform to auth an application to post to the page, and how to actually post the message?

I do not have any userinput options at this point but the most guides I have found requires user input in some auth dialogs and such. It must be possible to auth the app, and then request a token and post the page right?

Matt Tester
  • 4,663
  • 4
  • 29
  • 32
Jonas Cannehag
  • 391
  • 2
  • 11

1 Answers1

4

Follow step 1 to 4 here: http://developers.facebook.com/docs/authentication/server-side/

Make sure you enter 'manage_pages' and 'publish_stream' permission in step 1. This should give you a valid access token.

With this access token, you call the following api method: (replace xxxxxxx with access_token)

https://graph.facebook.com/me/accounts?access_token=XXXXXXXX

In the output you should see something similar to this:

    {
   "data": [
      {
         "name": "My App",
         "category": "Application",
         "id": "10258853",
          "access_token": "yyyyyyyyyyyyyy"
      }
   ]
}

Using the yyyyyyyyyyy access_token you can publish to any wall like you would do as a user.

https://graph.facebook.com/ThePageId/feed/message=MyFirstPost&access_token=yyyyyyyyyyyyyy

I've been asking the same before. See my question here for the code i was using then. I think you should manage with that and my answer above.

I hope i could make at least a few things clear for you. If not, ask me and i'll try to help you out.

Community
  • 1
  • 1
ThdK
  • 9,916
  • 23
  • 74
  • 101
  • Just a question, the first thing stated in the "Follow step..." is this: "Redirect the user to the OAuth Dialog". Is this some kind of initial setup, since i cannot do this when there is not user interface – Jonas Cannehag May 11 '12 at 09:13
  • It's been a while i was doing this, but i think you can save the yyyyyyyyy somewhere in your config of you cms application because it will stay the same. Then, whenever you need to publish on a page as your application, use this access token. – ThdK May 11 '12 at 09:21
  • The xxxxx access_token will expire, the yyyyy normally wont. Here's the facebook documentation about authentication as an app. Maybe this is the documentation instead of the one i posted previously :s https://developers.facebook.com/docs/authentication/applications/ "App access tokens do not expire unless you refresh you app's App Secret." – ThdK May 11 '12 at 21:22
  • The access_token returned from that guide is not allowed to post to my page – Jonas Cannehag May 12 '12 at 05:11
  • Did you ask for publish_stream permission during authentication? – ThdK May 12 '12 at 12:44