我正在开发一个Unity游戏,你可以拍照并上传到Facebook,同时附带一些标签和其他内容(类似于Friendsmash)。问题是我没有可用于放置截图的Web服务器,并且Fb.Feeb(picture:)属性仅接受URL。
我已经了解到可以使用HTTP POST将图片发布到用户的图像中,然后在picture:中使用该链接,但我对HTTP POST一无所知,也无法弄清楚如何操作。
我还读到可以使用FB.API()来实现此操作,但我无法理解它。
非常感谢提供任何示例代码。
我的当前代码:
我已经了解到可以使用HTTP POST将图片发布到用户的图像中,然后在picture:中使用该链接,但我对HTTP POST一无所知,也无法弄清楚如何操作。
我还读到可以使用FB.API()来实现此操作,但我无法理解它。
非常感谢提供任何示例代码。
我的当前代码:
private string _path = "file://" + System.IO.Path.Combine(Application.persistentDataPath, "Images/image.png");
void Start ()
{
if (!FB.IsLoggedIn)
FB.Login("email, publish_actions, publish_stream, user_photos", LoginCallback);
StartCamera();
}
private void OnBragClicked()
{
FbDebug.Log("OnBragClicked");
//Post(); <-- dont know how
FB.Feed(
linkCaption: "#hashtag",
picture: "???",
linkName: "Im hashtaging!",
link: "https://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
);
}
void TakeSnapshot()
{
_snap = new Texture2D(_webCamTexture.width, _webCamTexture.height);
_snap.SetPixels(_webCamTexture.GetPixels());
_snap.Apply();
//System.IO.File.WriteAllBytes(_path, _snap.EncodeToPNG());
}