【发布时间】:2016-05-08 16:19:09
【问题描述】:
我正在尝试发布屏幕截图并将其上传到用户的 Facebook 帐户。我正在使用 unity (c#) 并使用 facebook SDK,它与我从他们的文档中获得的示例代码一起工作正常。
我什至设法“预先填写”了一条消息并将其与屏幕截图一起发布。但是预填消息是违反Facebook Platform Policyexanples的,所以我正在寻找一种方法来使用相同的方法,让用户在不违反Facebook平台政策的情况下填写消息。
这是我使用的工作代码:
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");
wwwForm.AddField("message","some message"); // violating Facebook Platform Policy
FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
}
【问题讨论】:
标签: android facebook facebook-graph-api unity3d