我在将屏幕截图发布到 FB 时遇到问题。连接不是问题,因为我收集、反序列化并显示我的 fb 数据。向朋友发布分数和消息工作正常,但我无法通过手机发布镜头。我正在使用 Eclipse 进行调试,但我没有收到任何错误。我的代码如下所示:`
IEnumerator TakeScreenShot()
{
//coroutine because I want to wait until end of the frame for shot
yield return new WaitForEndOfFrame();
//create new texture that will be my screenshot
Texture2D tex = new Texture2D(Screen.width,Screen.height,TextureFormat.RGB24, false);
// read pixels from screen
tex.ReadPixels(new Rect(0,0,Screen.width,Screen.height),0,0);
//and apply them to texture
tex.Apply();
// now we have screenshot
// now we need to encode texture to array of bytes
byte[] buffer = tex.EncodeToPNG();
//so we can save it to storage
// System.IO.File.WriteAllBytes(Application.dataPath + "/screenshots/screen/screen" + ".png", buffer);
//or to convert it to string for posting to facebook
string s = Convert.ToBase64String(buffer);
//????? maybe my string format is not correct
var query = new Dictionary<string, string>();
query["photos"] = s;
FB.API("me?fields=photos",Facebook.HttpMethod.POST, delegate (string r) { ; }, query);
}
` 当我去 GraphExplorer 并粘贴命令“me?fields=photos”时,我什么也得不到。这意味着函数什么也没做。我忘了说我授予了 user_photos 的权限。这令人沮丧。我在看起来微不足道的问题上浪费了三天时间,但看不到解决方案。我将不胜感激任何建议。