Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to post a link with a picture to Facebook using the Graph API?

I have tried two different methods.

The first is to specify the link in the /PROFILE_ID/feed link argument (as described under "publishing" here). The problem is that if I specify anything other than my application URL i get an error saying the URL is invalid.

The second is to use the /PROFILE_ID/links method and specifying a picture URL. The problem is that when it posts it only shows the message and the URL. I've specified values for picture, name and message but none of them show.

How can I Post a link, with a name, message and picture?

like image 824
Abe Miessler Avatar asked Dec 03 '10 17:12

Abe Miessler


Video Answer


2 Answers

Your first approach is the correct one. Is your url starting with http://? What SDK are you using?

As described on this page, the example suggest it should work. http://developers.facebook.com/docs/reference/api/post

curl -F 'access_token=...' \
 -F 'message=Check out this funny article' \
 -F 'link=http://www.example.com/article.html' \
 -F 'picture=http://www.example.com/article-thumbnail.jpg' \
 -F 'name=Article Title' \
 -F 'caption=Caption for the link' \
 -F 'description=Longer description of the link' \
 -F 'actions={"name": "View on Zombo", "link": "http://www.zombo.com"}' \
 -F 'privacy={"value": "ALL_FRIENDS"}' \
 -F 'targeting= {"countries":"US","regions":"6,53","locales":"6"}' \
 https://graph.facebook.com/me/feed
like image 81
Nicolas Grasset Avatar answered Oct 07 '22 21:10

Nicolas Grasset


I ended up solving this problem by using the /PROFILE_ID/feed method and then disabling Stream post URL security in my application security settings. Hope this helps someone!

like image 26
Abe Miessler Avatar answered Oct 07 '22 21:10

Abe Miessler