How to share high score(string)/game result data on facebook ...please any one help me ....:(.

Friends i really need your help … its been i am trying to just show my game result on facebook :(…what i want, at the end of my game i get a result in string like high score… i just want to show that on face book as to post on your own facebook wall … i have installed facebook sdk 5.1, made an app id on developers.facebook page … put that name and the app id in the facebook settings in the unity3d editor … but i am not figuring it out how we will share the result … i tried to get help from the friendssmash but its complicated … they are not showing properly … is there any other scripts that we need to write …there will be … please help me … i am stuck at the end of my game … :"(

2 Answers

2

With the Facebook SDK for Unity you will need to call the FB.Feed function and give it the good parameters. Just add your score in the linkDescription or in the linkName.

Take a look at this link: FB.Feed Reference

Exemple:

FB.Feed(
    link: "https://example.com/myapp/?storyID=thelarch",
    linkName: "The Larch",
    linkCaption: "I thought up a witty tagline about larches",
    linkDescription: "There are a lot of larch trees around here, aren't there?",
    picture: "https://example.com/myapp/assets/1/larch.jpg",
    callback: LogCallback
);

void LogCallback(FBResult response) {
    Debug.Log(response.Text);
}

To fix the optional parameter error move line 17 to the top of the parameters list. Or give it a default value.

I think ur getting this error because u are running it in the editor. Have u tryed to test it directly on facebook?

Also there should be somewhere in ur script that you use FB.Login, otherwise i doubt that you will be able to use FB.Feed private void SetInit() { FB.Login("publish_actions", OnLoggedIn); } void OnLoggedIn(FBResult result) { if (FB.IsLoggedIn) { Debug.Log("Logged in successfully"); } }

Ok now everything is checked .... my facebook setting in the editor have no error and it shows hashkey as well ... now when i click on the editor in the unity it shows me access token .. i write the access token and login .. after that it show me the dialog to post on your wall and it posts perfectly and user can see it but now when i built in my tablet it show the log in button . press the button it will show login page , user get log in but doesn't show the next button .. now which part is missing seriously :'( :( :( :'( .... why its not working on tablet ....

try using the DDMS... use the link I gave you. Having the error message would help tremendously. I'm 95% sure that something goes wrong on the FB.Login function on your tablet, but I just dont know what, so having the logs would help alot.

Actually in the fb.Init() i removed the OnHideUnity and it works … in OnHideUnity game get pause before sharing … strange … Thanks for all of you for help … :slight_smile: