Hi, I am trying to publish a feed to facebook, but it doesnt post the description and caption. I tried it with Interactive console example also.
Here is my code :
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public sealed class FbShareHighscore : MonoBehaviour {
protected string lastResponse = "";
void Awake(){
CallFBInit();
//FeedProperties.Add("key1", new[] { "valueString1" });
//FeedProperties.Add("key2", new[] { "valueString2", "http://www.facebook.com" });
}
public void publishFeed(){
lastResponse="publishFeed Clicked";
if(FB.IsLoggedIn){CallFBFeed();}
else{
CallFBLogin();
}
}
#region FB.Init()
private void CallFBInit()
{
FB.Init(OnInitComplete, OnHideUnity);
}
private void OnInitComplete()
{
Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
lastResponse="FB.Init completed: Is user logged in? " + FB.IsLoggedIn;
}
private void OnHideUnity(bool isGameShown)
{
Debug.Log("Is game showing? " + isGameShown);
}
#endregion
#region FB.Login()
private void CallFBLogin()
{
FB.Login("email,publish_actions", LoginCallback);
}
void LoginCallback(FBResult result)
{
if (result.Error != null)
lastResponse = "Error Response:
" + result.Error;
else if (!FB.IsLoggedIn)
{
lastResponse = “Login cancelled by Player”;
}
else
{
lastResponse = “Login was successful!”;
CallFBFeed();
}
}
private void CallFBLogout()
{
FB.Logout();
}
#endregion
#region FB.Feed()
public string FeedToId = "";
public string FeedLink = "";
public string FeedLinkName = "";
public string FeedLinkCaption = "Available on Google Play and iOS";
public string FeedLinkDescription = "Check out my high score";
public string FeedPicture = "";
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[]>();
private 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: Callback
);
}
#endregion
protected void Callback(FBResult result)
{
// Some platforms return the empty string instead of null.
if (!String.IsNullOrEmpty (result.Error))
{
lastResponse = "Error Response:
" + result.Error;
}
else if (!String.IsNullOrEmpty (result.Text))
{
lastResponse = "Success Response:
" + result.Text;
}
else if (result.Texture != null)
{
lastResponse = "Success Response: texture
";
}
else
{
lastResponse = “Empty Response
“;
}
}
void OnGUI(){
GUI.Label(new Rect(10,(Screen.height/4),Screen.width,Screen.height/2),”:”+lastResponse);
}}