简体   繁体   English

UNITY-FB SDK:屏幕快照未在个人资料上发布

[英]UNITY - FB SDK : screenshot not getting posted on profile

I am trying to integrate FB SDK in my UNITY GAME for ios and ANDROID. 我正在尝试将FB SDK集成到适用于ios和ANDROID的UNITY GAME中。
FB SHARE AND INVITE are working fine which are in "FBSCENE" scene. 在“ FBSCENE”场景中,FB共享和邀请工作正常。
But in "GAME" scene i want to take a SCREENSHOT after game is finished and post it on users FB WALL. 但是在“游戏”场景中,我想在游戏结束后进行屏幕截图并将其发布到用户FB WALL上。
I read "Take and publish a screenshot" under EXAMPLE at https://developers.facebook.com/docs/unity/reference/current/FB.API and my code is this 我在https://developers.facebook.com/docs/unity/reference/current/FB.API上的 “示例”下阅读了“获取并发布屏幕截图”,我的代码是这样

public void screenShareFB()
{
    callFB ();
}
void callFB () {
    if (!FB.IsLoggedIn) {
        FB.Login("email,publish_actions", LoginCallback);                                                                                                                                                                
    }
    else {
        StartCoroutine(TakeScreenshot());
    }
}

void LoginCallback(FBResult result) {                                                                                          
    FbDebug.Log("LoginCallback");                                                          
    if (FB.IsLoggedIn) { 
        StartCoroutine(TakeScreenshot());
    }                                                                                      
}
/*
void OnLoggedIn() {                                                                                          
    FbDebug.Log("Logged in. ID: " + FB.UserId);                                            
}*/

private IEnumerator TakeScreenshot() {
    yield return new WaitForEndOfFrame();

    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();

    var wwwForm = new WWWForm();
    wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png");
    wwwForm.AddField("message", "herp derp.  I did a thing!  Did I do this right?");

    FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
    Debug.Log("done");
}
private Texture2D lastResponseTexture;
private string lastResponse = "";
public string ApiQuery = "";
void Callback(FBResult result)
{
    lastResponseTexture = null;
    if (result.Error != null)
        lastResponse = "Error Response: " + result.Error;
    else if (!ApiQuery.Contains("/picture"))
        lastResponse = "Success Response: " + result.Text;
    else
    {
        lastResponseTexture = result.Texture;
        lastResponse = "Success Response: ";
    }
}

screenShareFB() being called when user tap on SHARE SCREENSHOT button. 当用户点击SHARE SCREENSHOT按钮时,将调用screenShareFB()。
NOTE: 注意:
I have called FB.Init(with a call back method); 我已经调用FB.Init(带有回调方法); in Start() of the script. 在脚本的Start()中。
I am using C# script. 我正在使用C#脚本。
Is this because my app is not live on facebook ? 这是因为我的应用程序不在Facebook上吗?
I have configured it on facebook already. 我已经在facebook上配置了它。
I was testing on PC. 我在PC上进行测试。

Please tell me if anything is wrong with the code or any thing i am missing. 请告诉我代码是否有问题或我缺少什么。

The problem was permissions. 问题是权限。
the "publish_actions" permission was not review by facebook. Facebook未审核“ publish_actions”权限。
thus the screenshot was not getting published. 因此屏幕截图未发布。
but 1 thing when try to fill details for fb to review my app and allow me to access publish_actions for my user. 但是尝试填写fb的详细信息以查看我的应用并允许我为我的用户访问publish_actions时是一件事情。
They require us to add a "platform" under "SETTINGS" in "BASIC". 他们要求我们在“基本”的“设置”下添加“平台”。
Now i am using UNITY. 现在我正在使用UNITY。
which is not mentioned as a platform there. 那里没有提到作为平台。 What should i do.? 我该怎么办。?

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

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