Share custom message, link and image on facebook v

2019-03-06 16:08发布

问题:

I want to implement facebook sharing. I tried using the facebook sharer.php but it no more accepts custom parameters (deprecated by facebook). Also, I saw an option to use the FB.api to post on facebook.

I just want to know the correct syntax for doing this using FB.api where I can share some custom message, image and link. P.S. - The application that I am working on is Java based and pages are jsp pages.

Thanks in advance.

回答1:

Messages must be 100% user generated, prefilling is not allowed - if that is what you mean with "custom message". That being said, there is the FB.ui share dialog: https://developers.facebook.com/docs/sharing/reference/share-dialog

It works similar to sharer.php and only takes the URL as parameter. That´s the recommended way, you just need to add the correct Open Graph tags to the shared URL.

Another possible way to share something is to use the feed endpoint of the user object: https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed#publish

...but you need to authorize the user with publish_actions for that, and you have to go through a review process on Facebook before you can go public with that permission. Obviously, you will not get approved if you prefill the message parameter.

More information about sharing in general: https://developers.facebook.com/docs/sharing