dbrianj
dbrianj

Reputation: 472

Facebook Open Graph - standard action og.likes with custom Object type

I'm trying to create a basic demo on Android that uses the Native Share Dialog from the Facebook SDK/application. However, when I try to create a story with the action "og.likes" and use my custom object, it gets created by Facebook as a basic "object" type instead of the custom type I've defined. So instead of the story saying "Johnny likes a git repository" like it should, it says "Johnny likes an object".

Here is the code I am using:

public void shareOpenGraphStory(Intent intent) {
    OpenGraphObject obj = OpenGraphObject.Factory.createForPost("qtino-sharing:git_repo");
    obj.setType("qtino-sharing:git_repo");
    obj.setTitle("Testing OpenGraph Share");
    Log.w("FBShareActivity", "Object type is " + obj.getType());

    OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
    action.setType("og.likes");
    action.setProperty("object", obj);

    FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(mainActivity, action, "og.likes", "object")
            .setFragment(this)
            .build();
    uiHelper.trackPendingDialogCall(shareDialog.present());
}

I'm pretty sure I've properly defined my custom object type in the Facebook Developer center, as I can successfully share open graph stories using this type with a custom action that I've also defined.

The type of this object gets set properly, as verified by the log statement that gets printed, and the open graph story posts without error (I can see it on my facebook wall). However, in the object browser, the og:type of the object shows "object" instead of "git_repo", and after hours of poring through documentation and scouring SO I still can't figure out why.

Can anyone see something I'm doing wrong? Or do you know if it's even possible to use derived object types with the 'og.likes' action type when sharing via the native share dialog.

Upvotes: 3

Views: 837

Answers (1)

ergoon
ergoon

Reputation: 1264

I had the same problem and I couldn't fix it with the common action "og.likes". I ended up creating a custom action ("Suggest" in my case), added an object type ("Product" in my case) and added the type as a property of my custom action.

Then I was able to create a new story ("Suggest a product") and post this story to my feed with the correct title (the name of the product).

It's a little more work, especially because I needed to find a good action name that replaces "og.likes", but I still find it more suitable then having it say "liked an object".

Example:

OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);

action.setType("<my_app_namespace>.<my_custom_action>");
action.setProperty("<my_custom_action_property_name>", obj);

Upvotes: 1

Related Questions