Publish Facebook Open Graph stories with a friend profile - Plunge Interactive

Publish Facebook Open Graph stories with a friend profile

This post involves the use of the use of the Facebook plugin for Cocos2d-x, that is Ezisocial.

You must have seen open graph stories from Candy Crush Saga in which they publish about a Facebook user passed another user (who is friend) in the game. It looks like the screenshots shown below:

Candy_Crush_OG

With EziSocial Plugin it is relatively simple to publish such open graph stories. Let’s take a look now.

Prerequisite

You must read my other tutorials on open graph stories before reading this tutorial otherwise you may get confuse at some point.

In this tutorial and sample app, we will try to publish a open graph story that will describe that a Facebook User (that is me) has defeated a another user (my friend) on EziSocialDemo app. It will look like as shown in below picture.

Defeat_A_Friend

Are you interested now? Cool ! Let’s begin the tutorial.

Here are steps to build action with a profile kind of story:-

  1. Create a open graph story and action with a profile
  2. Set EziFacebookDelegate as super class
  3. Define virtual method for callback
  4. Call function publishOpenGraphActionWithFriend
  5. Understanding response in callbacks
  6. Viewing published open graph story

Step 2, 3, 5, and 6 are same as described in tutorial “Publish Open Graph Stories“. So I would not be repeating here. I will describe only step #1 and step #4 to keep brevity of the tutorial.

Step 1: Create a open graph story and action with a profile

For this type of story, we need to build special kind of story with a profile. Go to your apps and then go to stories (will be showing in left pane). Lets create a new story.

App_Edit

A pop will be shown (see picture below) and create your desired action:pass or defeat or anything you like. Now in second table you must selectprofile.

Defeat_A_Profile_Story_Create

Go ahead and create the story. Edit the story as per your need otherwise it is good to go and lets save the story. Now you can follow the step 2 andstep 3 from previous tutorial. If you have already done with that then lets jump on step 4.

Step 4: Call function publishOpenGraphActionWithFriend

We have a special function for this: publishOpenGraphActionWithFriend

It has only two parameters:

1
void EziSocialObject::publishOpenGraphActionWithFriend(const char* friendID, const char* actionType)

friendID – Facebook ID of user’s friend. Make sure it is valid Facebook User ID
actionType – In our case action is defeat

Let’s see a example code:

1
2
3
4
5
6
7
void HelloWorld::defeatAFriend()
{
        EziSocialObject::sharedObject()->publishOpenGraphActionWithFriend(“090379379120”, // Replace with user’s Facebook Friend ID
                                                                          “defeat”);
        EziSocialObject::sharedObject()->logEvent(“Defeat a friend”);
}

That’s it. If you have configured callback properly then you will see the response within the game.

This site uses cookies to store information on your computer. Some cookies on this site are essential, and the site won't work as expected without them. Read more about them

ACCEPT