开发者

How to post to a fan page from an application as the brand?

I want to post a message to a fan page from an application as the brand using the Facebook SDK.

I tried using the following token and code to开发者_如何学Go post to a fan page, but I get a bad request error:

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

With output similar to the following:

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

What am I doing wrong?


The data you are receiving seems to be your own account details.

To be able to post to a feed your app needs to:

  • Be authenticated
  • Have the publish_stream permission from the owner of the feed
  • Use this url: https://graph.facebook.com/CLIENT_ID/feed?access_token=XXXXXX where CLIENT_ID is the id of the feed-owner.
  • set message to be posted as a post variable named message in the request
  • be sent as a POST

hope these points help you out.


Ok, actually my sollution seemed to be just fine :) Here's how to do it: 1. Make sure you are administrator of the facebook page on wich you want to post. 2. Get your access_token here:

https://www.facebook.com/dialog/oauth?
   client_id=[APP ID]
&response_type=token
&scope=publish_stream,manage_pages, offline_access
&redirect_uri=[The page you want to be redirected after you get you token, must be the same domain as your application]

3. Get your access_token for a specific page/application here:

https://graph.facebook.com/me/accounts?access_token=[ACCESS_TOKEN FROM STEP 2]

You'll see something like this:

{
     "name": "Your Page",
     "category": "Community",
     "id": "145530142139075",
     "access_token": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
  },

4. You can now start posting to your page.

    https://graph.facebook.com/[YOUR PAGE ID FROM STEP 3]/feed
access_token=[ACCESS_TOKEN FROM STEP 3]

I hope this will help others.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜