facebook "share button" for mobile web html/javascript

dvrm picture dvrm · Jan 3, 2013 · Viewed 7.5k times · Source

i want to add a facebook share button to my mobile web app for sharing specific content from my app as picture with text etc.

but i'm really confused!!!

is the "share button" is depracated? what to use for its behavior instead?

I read a lot in the facebook developers site but couldn't find any code example to use.

please help me implement this. any piece of code will be welcome!!

here is the solution i used thanks to mrtom solution (the first option):

add this to your html file:

  <a href="http://www.facebook.com/dialog/feed?app_id=your_app_id&  
link=http://developers.facebook.com/docs/reference/dialogs/&  
picture=http://fbrell.com/f8.jpg&  
name=Facebook%20Dialogs&caption=Reference%20Documentation&description=Dialogs%20provide%20a%20simple,%20consistent%20interface%20for%20applications%20to%20interact%20with%20users.&message=Facebook%20Dialogs%20are%20so%20easy!&  
redirect_uri=your_Mobile_Site_URL">share</a>

you must change the app_id and the redirect_uri to yours.
other parameters you can change as you want

in https://developers.facebook.com/docs/reference/dialogs/feed/ you can find properties table of all the properties you can specify.

ask if something is not clear.

Answer

mrtom picture mrtom · Jan 3, 2013

The answer depends on the functionality you want.

You can use the feed dialog - https://developers.facebook.com/docs/reference/dialogs/feed/ - to post to Facebook as a user, i.e. equivalent to the user posting a status update

You can use the Graph API directly if you have a user access token with publishing permissions. The Feed Dialog docs above show an example of how to do this, or take a look at https://developers.facebook.com/docs/reference/api/user/. Just hook up your own button to make the request, either via your server or using the Javascript SDK.

You can use the send button - https://developers.facebook.com/docs/reference/plugins/send/ - to allow your users to send your content to a specific friend

Or, finally, you can use sharer.php. Can't find any docs on that right now, but a simple Google search for 'Facebook sharer.php' should help you out.