Android Facebook SDK统一发布
我正在开发一款Android游戏,在其中我连接到Facebook。如果用户已连接,他们可以在Facebook墙上发布应用程序 问题在于,在脚本Android Facebook SDK统一发布,android,facebook,unity3d,facebook-unity-sdk,Android,Facebook,Unity3d,Facebook Unity Sdk,我正在开发一款Android游戏,在其中我连接到Facebook。如果用户已连接,他们可以在Facebook墙上发布应用程序 问题在于,在脚本InteractiveConsole.cs中,当用户单击“发布”按钮,然后单击“取消”按钮时,我希望显示此消息:“未发布”。 当他们只点击发布按钮并发布时,我想显示消息:“发布” 问题是,在这两种情况下,当我决定发布或取消时,它会在GUI上显示消息:“发布” 这是我的密码: public GUIText guiFeed; #region FB.Feed(
InteractiveConsole.cs
中,当用户单击“发布”按钮,然后单击“取消”按钮时,我希望显示此消息:“未发布”。
当他们只点击发布按钮并发布时,我想显示消息:“发布”
问题是,在这两种情况下,当我决定发布或取消时,它会在GUI上显示消息:“发布”
这是我的密码:
public GUIText guiFeed;
#region FB.Feed() example
public string FeedToId = "";
public string FeedLink = "http://www.google.com";
public string FeedLinkName = "Test";
public string FeedLinkCaption = "Test Caption ";
public string FeedLinkDescription = "Test Deszcription";
public string FeedPicture = "http://www.selfspark.com/wp-content/uploads/Smiley-Face-Button.jpg";
public string FeedMediaSource = "";
public string FeedActionName = "";
public string FeedActionLink = "";
public string FeedReference = "";
public bool IncludeFeedProperties = false;
private Dictionary<string, string[]> FeedProperties = new Dictionary<string, string[]>();
public void CallFBFeed()
{
Dictionary<string, string[]> feedProperties = null;
if (IncludeFeedProperties)
{
feedProperties = FeedProperties;
}
FB.Feed(
toId: FeedToId,
link: FeedLink,
linkName: FeedLinkName,
linkCaption: FeedLinkCaption,
linkDescription: FeedLinkDescription,
picture: FeedPicture,
mediaSource: FeedMediaSource,
actionName: FeedActionName,
actionLink: FeedActionLink,
reference: FeedReference,
properties: feedProperties,
callback: LogCallback
);
}
void LogCallback(FBResult response)
{
Debug.Log(response.Text);
guiFeed.text = "response Feed:"+response.Text;
if (response.Text == null)
{
feedd.text = "not publish";
}
else
{
feedd.text = " publish";
}
}
#endregion
公共吉他文本guiFeed;
#region FB.Feed()示例
公共字符串FeedToId=“”;
公共字符串FeedLink=”http://www.google.com";
公共字符串FeedLinkName=“Test”;
公共字符串FeedLinkCaption=“测试标题”;
公共字符串FeedLinkDescription=“测试描述”;
公共字符串FeedPicture=”http://www.selfspark.com/wp-content/uploads/Smiley-Face-Button.jpg";
公共字符串FeedMediaSource=“”;
公共字符串FeedActionName=“”;
公共字符串FeedActionLink=“”;
公共字符串FeedReference=“”;
public bool IncludeFeedProperties=false;
私有字典FeedProperties=新字典();
public void CallFBFeed()
{
Dictionary feedProperties=null;
if(IncludeFeedProperties)
{
feedProperties=feedProperties;
}
饲料(
toId:FeedToId,
链接:FeedLink,
linkName:FeedLinkName,
linkCaption:FeedLinkCaption,
linkDescription:FeedLinkDescription,
图片:FeedPicture,
mediaSource:FeedMediaSource,
actionName:FeedActionName,
actionLink:FeedActionLink,
参考:FeedReference,
属性:feedProperties,
回调:LogCallback
);
}
无效日志回调(FBResult响应)
{
Debug.Log(response.Text);
guiFeed.text=“响应提要:”+response.text;
if(response.Text==null)
{
feedd.text=“不发布”;
}
其他的
{
feedd.text=“发布”;
}
}
#端区
取消Facebook共享时,响应中的已取消
字段有一个真正的布尔值
首先,您应该将响应JSON从字符串解析到字典,然后检查它是否存在以及它是否为正值,这意味着取消共享
您应该像这样更新代码:
void LogCallback(FBResult response)
{
var responseObject = Json.Deserialize(response.Text) as Dictionary<string, object>;
object cancelled;
if (responseObject.TryGetValue ("cancelled", out cancelled))
{
if( (bool)cancelled == true )
{
feedd.text = "not publish";
}
else
{
feedd.text = "publish";
}
}
else
{
feedd.text = "publish";
}
}
void日志回调(FBResult响应)
{
var responseObject=Json.Deserialize(response.Text)为字典;
对象被取消;
if(responseObject.TryGetValue(“已取消”,未取消))
{
如果((bool)取消==真)
{
feedd.text=“不发布”;
}
其他的
{
feedd.text=“发布”;
}
}
其他的
{
feedd.text=“发布”;
}
}