我正在尝试让我的应用程序(iOS、Android)允许用户将屏幕截图发布到 Facebook,并附上链接和描述。我可以使用 FB.API() 将我的应用程序的屏幕截图上传到 Facebook 为我的应用程序自动生成的用户相册,方法是:
int width = Screen.width;
int height = Screen.height;
Texture2D 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();
string picName = "Idioman_" + Time.time + ".png";
wwwForm.AddBinaryData("image", screenshot, picName);
Debug.Log("trying to post screenshot");
FB.API("me/photos", Facebook.HttpMethod.POST, PostPicCallback, wwwForm);
我可以使用 FB.Feed() 从互联网上发布图像,并附上用户提要的链接和描述。有没有办法将屏幕截图发布到用户的提要中,并附上链接和描述?
var snap = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
snap.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
snap.Apply();
var screenshot = snap.EncodeToPNG();
int i = UnityEngine.Random.Range (0, 2);
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", screenshot, "picture.png");
wwwForm.AddField ("name", "this will be the caption for the image");
FB.API("me/photos", HttpMethod.POST, CallbackUploadImage, wwwForm);
您可以参考此处了解可用字段的更多详细信息
https://developers.facebook.com/docs/graph-api/reference/v2.2/photo https://developers.facebook.com/docs/graph-api/reference/v2.2/photo
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)