簡體   English   中英

Unity3D-無法將截圖分享到Facebook

[英]Unity3D - Cannot Share Screenshot to Facebook

我正在嘗試使用unity3D將屏幕快照圖像共享給Facebook。 我可以通過Unity登錄到Facebook,登錄后可以訪問我的個人資料照片。

現在,我想拍攝我的應用程序的屏幕截圖並將其分享到Facebook。 我使用從Facebook開發人員頁面獲取的以下代碼進行了此操作:

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, "Screenshot.png");

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

但是我得到的結果是“ 403 Forbidden”。 我在這里做錯了什么? 還是有其他方法可以使用Unity將截圖分享到Facebook。

任何幫助將不勝感激。

普拉巴

有兩件事要確保。

1。確保您具有發布權限

2。如果您具有發布權限,則構建項目並在物理Android設備上運行它。 當你運行它,您將能夠使從編輯帖子截圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM