1
\$\begingroup\$

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.

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

2 Answers 2

0
\$\begingroup\$

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

\$\endgroup\$
2
  • \$\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
    Commented Nov 23, 2015 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
    Commented Nov 23, 2015 at 13:28
0
\$\begingroup\$

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

\$\endgroup\$
1
  • \$\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
    Commented Aug 3, 2017 at 16:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .