简体   繁体   English

与文本共享屏幕截图到 facebook unity

[英]Sharing screenshot with text to facebook unity

I'm trying to give the user the possibility to post a screenshot of his game on facebook with the dowload link of the game.我试图让用户可以通过游戏的下载链接在 facebook 上发布他的游戏截图。

I've looked a bit and it seemed it would be possible with FB.API, but I can't manage to make it work.我看了一点,似乎可以使用 FB.API,但我无法让它工作。 Aparently you need a permission but I can't to find which permission and how to give it. Aparently 你需要一个许可,但我无法找到哪个许可以及如何给予它。

I'm using unity 2020.3.21f1我正在使用统一 2020.3.21f1

Here is what I'm doing for now这是我现在正在做的事情

public void ShareScreenShot(Texture2D screenShot)
{
    byte[] encodedScreenShot = screenShot.EncodeToPNG();

    var wwwForm = new WWWForm();
    wwwForm.AddBinaryData("image", encodedScreenShot, "ScreenShot.png");
    wwwForm.AddField("message", "Venez me défier : https://randomlink.blablabla");

    FB.API("me/photos", HttpMethod.POST, ShareScreenShotCallback, wwwForm);
}

void ShareScreenShotCallback(IResult result)
{
    if (result.Error != null)
    {
        Debug.Log(result.Error);
    }
    else
    {
        Debug.Log("sharing success");
    }
}

If anyone of you knows how it can be done, it would be of great help, thanks如果哪位大神知道怎么弄,那将是非常有帮助的,谢谢

I suppose you need to login to facebook with custom permissions, because the default one only allows you to send invitations to choosen friends.我想您需要使用自定义权限登录 facebook,因为默认权限仅允许您向选定的朋友发送邀请。

https://developers.facebook.com/docs/unity/reference/current/FB.LogInWithPublishPermissions/ https://developers.facebook.com/docs/unity/reference/current/FB.LogInWithPublishPermissions/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM