- Home /
Placing a Facebook screenshot in the FB.Feed after grabbing it with FB.API?
I'm using FB.API to grab a screenshot of my game, but I don't know how to retrieve the photo ID to put it as a link in FB.Feed. I've heard that you can grab the photo ID from the Callback in the FB.API, but I'm unsure how to do that. Anyone have any insight on this?
Code I'm using (C#):
private IEnumerator TakeScreenshot()
{
yield return new WaitForEndOfFrame();
var width = Screen.width;
var height = Screen.height;
var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
byte[] screenshot = tex.EncodeToPNG();
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
}
Answer by zzzzzz789 · Jul 28, 2015 at 01:15 AM
Using FB.API("me/photos", ...);
will post a photo to an album for the user, this resulting post will be rendered on their timeline and in friend's newsfeed so there is no reason to follow up with an additional FB.Feed();
If you would like to use FB.Feed();
with an image from your game without puting it into their photo albums, take a look at the Objects API, specifically staging_resources
: https://developers.facebook.com/docs/sharing/opengraph/object-api#objectapi-images
I'll check it out! Thank you for pointing me in the right direction :)