我正尝试使用Facebook SDK通过
FB.Feed()
而不是FB.API()
上传屏幕截图到Facebook,以使用户能够在其帖子中写下消息。我已经成功地在Unity Editor上实现了这一点,但是当我在Android上尝试时,我收到以下错误信息:
这是我编写的代码:"This dialog has been passed a bad parameter.
API Error Code: 100
API Error Description: Invalid parameter
Error Message: picture URL is not properly formatted"
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();
File.WriteAllBytes(Application.persistentDataPath + "/Screenshot.png", screenshot);
//Application.CaptureScreenshot(Application.persistentDataPath + "/Screenshot.png");
Debug.Log(Application.persistentDataPath + "/Screenshot.png");
Debug.Log("Does File Exist? " + File.Exists(Application.persistentDataPath + "/Screenshot.png"));
Debug.Log("File://" + Application.persistentDataPath + "/Screenshot.png");
FB.Feed(
picture: "File://" + Application.persistentDataPath + "/Screenshot.png"
);