Search code examples
facebookfacebook-likefacebook-javascript-sdkfacebook-sharer

Facebook Share using Friendly URL


I am trying to implement multiple Facebook share buttons in one page to share different pieces of content.

I was looking at this page: https://developers.facebook.com/docs/reference/dialogs/feed/

And tried to implement the Direct URL exactly as listed in the example:

https://www.facebook.com/dialog/feed?
app_id=123050457758183&
link=https://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&
name=Facebook%20Dialogs&
caption=Reference%20Documentation&
description=Using%20Dialogs%20to%20interact%20with%20users.&
redirect_uri=http://www.example.com/response

However, if you click on the link above and click share, you get an error message. How can I prevent the error message from happening and actually post the story to the feed when clicked shared?

Am I supposed to activate something else on my page? I want to make sure I can share different pieces of contents.

Any insight would be GREATLY appreciated :D.


Solution

  • To make the example work with your values you will need to set up a facebook application with the https://developers.facebook.com/apps page. It's important to set the domain and the site url of the application at the basic settings page since facebook validates the redirect_uri paremter of the feed dialog against those.

    Armed with the application's id, you can change the example's app_id and redirect_uri parameters and it should work.

    Edit:

    Since you are trying to use these on a facebook tab, take a look into facebooks javascript sdk. The FB.ui method makes these sharing interface more pleasant to use.