Facebook graph api

how to integrate Facebook into the cocos project am using cocos creator 2.4.6 version I need to show the user friends list to invite to the game.

am using typescript for scripting.

please share any git hub project so it will make my work easy thank you.

Hi @MADHUGT ,

You can use sdkbox and import Facebook plugin

check the below link for example and documentation

http://docs.sdkbox.com/en/plugins/facebook/

and here is the sample git hub link :

P.S : you can fetch fb friends only if your friends are playing that game

1 Like

I was looking at sonar systems web paige he has a Git with lots of diffrent frameworks, AdMob flurry and so on.

1 Like

thanks for the suggestion and help.

am working on the Facebook leaderboard for my game but FBInstant.context.getID(); this line of code returning me null value anyone has solution or git hub project using cocos 2.4.6 version please help me solve this.

const LEADERBOARD_NAME = “LEADERBOARD_NAME”;

  FBInstant.initializeAsync();

  FBInstant.startGameAsync();

  contextID = FBInstant.context.getID();

  console.log("fbinstance"+contextID);



  FBInstant.getLeaderboardAsync(LEADERBOARD_NAME + '.' + contextID)

    .then(function(leaderboard) {

      console.log(leaderboard.getName());

return leaderboard.setScoreAsync(Globals.Score, '{race: "elf", level: 3}');

    })

    .then()

    .catch(function(error) {

      display.error('Leaderboard is not found in app configuration');

    });

HI @MADHUGT ,

you can obtain contextid only if you are connected with someone
like play with friends, Facebook have updated their API.

if you refer the above link, you see that there are four context types
you can get context id 3 out of 4, leaving solo without any context id i.e, NULL

so for solo leaderboard you have to use your own server to store

1 Like

ok, I will try this thanks for the response :))