- Home /
Share an Image on Faceook
Hey guys, I want to share a screen shot to Facebook with other text content (if possible) or without any content. I found 2 way and I tried both of them none seems to be working perfectly.
I am using Facebook SDK for unity v7.2.2 and unity 5.4.2f2.
The 1st way I deed is using FB.Sharelink. Here is a step by step information about it. 1. Take the screenshot
Store to application.persistendatapath
Upload to other own hosted server
File successfully uploaded on server.
Now put the game for manual wait for 10 second for image uploading.
Once image uploaded on server Facebook sharing dialog appears on device. Current stored image is getting displayed on server.
Post it to Facebook. all post content were fine on dialog on device.
Result at end:. When I saw my post on Facebook i saw other no image and other text content was there.
No when I try to post it on second time what i found on Facebook share dialog is "instead of displaying current saved image on device, Facebook dialog shows previous shared image and when I post it to Facebook it shows other images. it didn't showed previous image also. in post it showing the image that was uploaded 2-3 days ago.
The 2nd way is using FB.API call. Here is the step by step information for executing it 1. Here is code for that
byte[] imgData = File.ReadAllBytes (Application.persistentDataPath + "/" + fUserName.Value +
pngExtention);
Texture2D imgtex = new Texture2D (333,333);
imgtex.LoadImage (imgData);
WWWForm wwwForm = new WWWForm ();
wwwForm.AddBinaryData("image",imgData,"temp.png");
FB.API ("me/photos", Facebook.Unity.HttpMethod.POST, ShareCallBack, wwwForm);
When I executed above code I got response back saying "403:Forbidden". It simply means I have authority to use respected website page.
I am using FB.LoginWithReadPermission with following permission :. public_profile, email, user_friends. Do I have to use FB.LoginwithWritePermission with particular permission ?
Please help me on this. Thanks in advance.
Answer by YHS · Dec 12, 2017 at 08:00 AM
You need ask "publish_actions" permission too. Check out the link below.
For anyone who is looking for share screenshot to FB directly, please check the answer there. https://stackoverflow.com/questions/45970150/how-to-share-screenshot-on-fb-with-unity-without-uploading-image/47767625#47767625