分享到Facebook显示错误“我们很抱歉,此帖已不再可用。它可能已被删除”

时间:2015-04-13 09:48:36

标签: android facebook facebook-graph-api unity3d

我尝试使用Unity 3D + Facebook Unity SDK在我的游戏中实现Facebook共享。但是,当我尝试测试发布到我的墙上时,出现此错误:"我们很抱歉,此帖已不再可用。它可能已被删除。"有谁能够帮我?提前谢谢。

BTW,这是我的代码:

using UnityEngine;
using System.Collections;

public class FacebookController : MonoBehaviour {

    public bool isUsingFacebook = true; //Are we using Facebook SDK? This variable is only 

    //Feed parameters.
    private string link = "market://details?id=com.LaserCookie.Queue"; //The link that will show the user the game's google play store address
    private string linkName = "Queue"; //The link name
    private string linkCaption = "Wow this game is great! 10/10 must play!"; // The caption of the link
    private string linkDescription = "I achieved the score of " + PlayerController.instance.score.ToString() + "! Try to beat me if you can!"; //The description of the link
    private string picture = "http://www.drycreekequestriancenter.com/testImage.jpeg"; //This is the image / game icon for the link. For now, it's shamelessly got from a random source. Thank you, random citizen...

    void Awake()
    {

    }

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }

    //Init FB
    private void Init()
    {
        if (!FB.IsInitialized)
        {
            FB.Init(OnInitComplete, OnHideUnity);
        }

    }

    //Callback that will be called when the initialization is completed
    private void OnInitComplete()
    {
        Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);

        //Check if we are logged in. 
        //If not, we will log in.
        //If we are, post status.
        if (!FB.IsLoggedIn)
        {
            LoginWithPublish();
        }
        else
        {
            PostImpl();
        }
    }

    //Callback that will be called when the game is shown / not
    private void OnHideUnity(bool isGameShown)
    {
        Debug.Log("Is game showing? " + isGameShown);
    }

    //Post to Facebook. This is the only exposed method because we only use this to post to Facebook.
    //The initialization and login will be called when needed.
    //It will first detect whether or not we have been initialized. And will init if we haven't.
    //Then it will check whether or not we have been logged in with publish. And will log in if not.
    public void PostToFacebook()
    {
        //Are we using facebook SDK?
        if (isUsingFacebook)
        {

            if (!FB.IsInitialized) //Check for initialization
            {
                Init();
            }
            else if (!FB.IsLoggedIn) //Check for login
            {
                LoginWithPublish();
            }
            else //Post if we are already initia;ized and logged in
            {
                PostImpl();
            }
        }
    }

    //The true implementation of the posting
    private void PostImpl()
    {
        FB.Feed("",link, linkName,linkCaption,linkDescription,picture);
    }


    //Login to Facebook with publish 
    private void LoginWithPublish()
    {
        // It is generally good behavior to split asking for read and publish
        // permissions rather than ask for them all at once.
        //
        // In your own game, consider postponing this call until the moment
        // you actually need it.
        FB.Login("publish_actions", LoginCallback);
    }

    //Login callback
    void LoginCallback(FBResult result)
    {
        if (result.Error != null)
        {
            Debug.Log( "Error Response:\n" + result.Error );

            //TODO: Retry login if we have error? Or do we display a pop up?
        }
        else if (!FB.IsLoggedIn)
        {
            Debug.Log( "Login cancelled by Player" );

            //TODO: Do we display a pop up?
        }
        else
        {
            Debug.Log( "Login was successful!" );

            PostImpl();
        }
    }

}

2 个答案:

答案 0 :(得分:1)

我已经解决了这个问题。事实证明,这是因为我使用我的开发谷歌商店地址作为链接。无论我的应用程序是否有效,我都认为它会被自动识别。还是非常感谢。 :)

答案 1 :(得分:1)

您需要为FB应用程序添加Key Hash。

转到我的应用程序,选择您的应用程序,打开设置选项卡,为Android添加平台,并添加密钥哈希。

检查此链接 Setting a Release Key Hash