gpt4 book ai didi

Facebook Unity API - 发布带有链接和描述的屏幕截图?

转载 作者:行者123 更新时间:2023-12-04 04:33:10 24 4
gpt4 key购买 nike

我正在尝试让我的应用程序(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

关于Facebook Unity API - 发布带有链接和描述的屏幕截图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20228436/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com