I'm trying to share an image taking from CaptureScreenshot() using FB.ShareLink(...) to Facebook.

My code is the following: (After calling FB.Init(), etc..)

 string tmpScreenshotPathname = "file:///" + currentScreenshotPathname;
 System.Uri contentUri = new System.UriBuilder(tmpScreenshotPathname).Uri;
 System.Uri imageUri = new System.UriBuilder(tmpScreenshotPathname).Uri;
 FB.ShareLink(contentUri, "Test", "Test desc", imageUri);

However, when open the FB share, the page opens for a split second before returning me back to the game. I tried using a normal Uri such as http://........jpg and it works fine, but when I try to use a local Uri, it fails.

Is there any way to share the image to the feed without uploading it to the user's Facebook gallery using FB.API? Because there's the case where the user might decide not to share the image to the feed.. but it would have already been uploaded to his gallery from FB.API.

  • \$\begingroup\$ Which platform is this for? I'm assuming Android since you mention URIs. \$\endgroup\$ – ZEKE Nov 22 '15 at 18:03
  • \$\begingroup\$ I'm using Unity, testing on Android. \$\endgroup\$ – Pat Nov 22 '15 at 18:52

Its not possible to upload a local image to Facebook. The image has to be on the cloud. You can try the alternative approach described in this answer - https://stackoverflow.com/a/32264318/3148917

  • \$\begingroup\$ What if the user presses cancel and doesn't share though? The picture would have already been uploaded to his account, just not shared, correct? Or is there a way to undo that? \$\endgroup\$ – Pat Nov 23 '15 at 12:58
  • \$\begingroup\$ Yes it will be uploaded to his album. Don't know any function which deletes a photo you need to research a bit :) \$\endgroup\$ – Hash Buoy Nov 23 '15 at 13:28

Follow these steps

  1. First login using FB.LogInWithPublishPermissions by adding"publish_actions" permission in parameters.
  2. Use Facebook Graph API to upload image

For more details link is here.. http://kayam83.blogspot.com/2017/08/how-to-share-screenshotimage-using.html

  • \$\begingroup\$ If the "more details" link ever changes, then this answer won't contain the critical API call to actually submit the image. It will be more future-proof if you include key information like this in the body of the answer, rather than relying wholly on an external link. You can still link for additional details and credit, but your answer should be able to stand on its own too. \$\endgroup\$ – DMGregory Aug 3 '17 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.