How do you post a custom story via the Facebook Unity SDK with a screenshot attached?
What I did:
Followed smash Unity tutorial. Created profile object. Created action smash. Created story smash + profile. Saved.
1) It says Unable to Generate Story. Is this a problem or can I still test my story?
Then based on the code from the tutorial, I wrote:
public void publishAction()
{
Debug.Log ("publish action.");
if (FB.IsLoggedIn)
{
Dictionary<string, string> querySmash = new Dictionary<string, string>();
string testUserID = "1378641979";
querySmash["profile"] = testUserID;
FB.API ("/me/" + FB.AppId + ":smash", Facebook.HttpMethod.POST, publishActionCallback, querySmash);
}
}
void publishActionCallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogWarning("FacebookManager-publishActionCallback: error: " + result.Error );
}
else
{
Debug.Log("FacebookManager-publishActionCallback: success: " + result.Text );
}
}
2) This code always return 400 Bad Request. Not sure why as it is a copy of the tutorial example. Any idea?
Next step, I would like to attached a screenshot of the game to this story. I do not have a web site to host it. I know how to get the screenshot.
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();
3) The question is how do I attach it to my custom story?
4) I am still unclear after doing some research on how to give my custom story a custom title and message. Please let me know how.
5) Finally, if my object is a new word (that is not predefined like profile is), what would my API call look like? Let's say custom story object is "meal".
Would it be: querySmash["meal"] = "A delicious pizza!"?
Thanks for your help!