Danish Iqbal
Danish Iqbal

Reputation: 1464

Howto use FB Graph to post a message on a page feed

I have created an app, and now i want to post a message on one of my pages wall with use of the new Graph API. Is this do-able?

below is the steps which i do

Using this to Get access code

https://www.facebook.com/dialog/oauth?client_id=1498653617947&redirect_uri=https://apps.facebook.com/post_on__my_page/index2.html&scope=email,read_stream,publish_stream,manage_pages,offline_access

Than use this to get access token

https://graph.facebook.com/oauth/access_token?client_id=1498653617947&redirect_uri=https://apps.facebook.com/post_on__my_page/index2.html&client_secret=seceret&code=AQDCqJNJnCvnFKVdbCyTp2vfzbT0ADbNgYsQ_2YtDdC_O2aIOwvkjx52HNcp3uiuBANJqOhb_M2sptB-lRrIECZxi5kZpzljez1J1oOtTp25gTnNDmV-RCVvR97DMiRAprNtwUBcstAotjsyYo5cNwJCWnkcgNigwhbQtE5Jp22sluVcZKhnO43cWQE#_=_

Now get page id and page access token from below

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

*use this to post on my page *

https://graph.facebook.com/1916117518646/feed?message:testmessage&access_token=aceess_token

any one please explain which point is wrong because instead of posting is just show posts details

i found that some thing wrong in this below code any one please suggest what and how to do

https://graph.facebook.com/1916117518646/feed?message:testmessage&access_token=aceess_token

Upvotes: 0

Views: 2530

Answers (2)

DMCS
DMCS

Reputation: 31880

I always highly suggest to people experimenting around for the first time to use the Graph API Explorer tool. It helps solidify the structure of the Graph and how to access it. See https://developers.facebook.com/tools/explorer

Another thing I always recommend is to lint the access_token you are trying to use. See https://developers.facebook.com/tools/lint. This is to ensure you have the right token with the correct permissions.

Also the access_token you use to post to a page must be a page token and not a user token. In your above example, it's unclear as to which one you're using since you've named both the same. I know you said you're using it, but with that variable name being the same, I always wonder.

Also the you need to do an HTTP Post and not an HTTP get to post a message. Again, play around in the graph API explorer until you can do it there. Once you've done it there, it's fairly trivial to do it with one of the SDKs.

Upvotes: 2

zerkms
zerkms

Reputation: 255115

You need to perform POST request, not GET, and pass parameters in POST body, not in the url

http://developers.facebook.com/docs/reference/api/user/#posts

http://facebook.stackoverflow.com/questions/691425/how-do-you-post-to-the-wall-on-a-facebook-page-not-profile

Upvotes: 0

Related Questions