- Home /
Can't Post Screenshot To Facebook Wall
Hey, I've seen a bunch of variations on this, but no definitive answer.
I want to capture a screenshot and post it to the user's wall. Obviously found out that uploading a photo can only happen through FB.API("me/photos"...., but this is not an actual share, and it does not let the user edit his share before posting it. Also got FB.Feed, which does not allow uploading a new photo, but only link to an existing photo on the web. So I tried uploading and then linking a share to the uploaded photo (http://graph.facebook.com/photo/{id}), but the feed window's response is: "fbcdn.net urls are not allowed". So, the options I see right now are either just upload a photo with a predefined text, or run my own CDN and upload the screenshots to it and link back to them in the feed call.
Is there (maybe, please, I really hope) any better way to this?
I have the same issue, while looking for an answer I stumbled upon this:
I haven't tried it yet, but might be a possible solution.
Have you found a solution to this?
I have posted a question on stack overflow too.
http://stackoverflow.com/questions/23912618/unity-facebook-sdk-can-not-post-picture-with-fb-feed
Answer by RonnyKibet · Aug 06, 2016 at 03:07 AM
Try this to take screenshot.
// create the texture
Texture2D screenTexture = new Texture2D(Screen.width, Screen.height,TextureFormat.RGB24,true);
// put buffer into texture
screenTexture.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height),0,0);
// apply
screenTexture.Apply();
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PHOTO
byte[] dataToSave = screenTexture.EncodeToPNG();
string destination = Path.Combine(Application.persistentDataPath, "RaceResults.png");
File.WriteAllBytes(destination, dataToSave);
print(destination);
//post to facebook
FB.FeedShare(
string.Empty, //toId
new System.Uri("https://enterlinkhere.com"), //app link
"PollyCube", //linkName
"LinkCaption", //linkCaption
"LinkDescription", //linkDescription
new System.Uri(destination), //picture
string.Empty, //mediaSource
ShareFeedCallback //callback or null
);