Unity facebook SDK, can not post picture with FB.F

2019-03-28 09:35发布

问题:

In my Unity IOS game, I am unsuccessfully trying to use FB.Feed to share a screenshot on the user's wall. Facebook documentation uses FB.Api to publish the screenshot, but this method does not display a share dialog, it simply uploads the pic to Facebook.

Answers I have found so far:

  1. Upload the picture using FB.Api, and then parse the FBResult for the picture URL, and feed that to FB.Feed Link to answer. This method triggers an error, since it is not possible to use a Facebook URL as source for a picture.

  2. Save the picture locally and prepend "File://" to the picture path. Link to question. This does not seem to work either, and the Facebook documentation does not seem to have any information on URL formatting.

My question:

Is this the correct (and only) way to display a share dialog when publishing a picture? Or am I looking in the wrong direction?

回答1:

FB.Feed only allows you to post link to images. It doesn't upload the images to Facebook. Therefore, these images need to hosted somewhere on the net and not locally.

The best way to make it work is either upload the images to FB (with privacy property set to EVERYONE) using FB.API, and then share the link to that picture via FB.Feed. If you don't want to create duplicate stories, i.e. one from posting the picture and another from FB.Feed, make sure that you set no_story to true.