Ad

How To Post Through Facebook Open Graph For Game

- 1 answer

I am developing some quiz app, and want to post player's achievement on facebook.

Since I want to post the image for the achievement and Link Share of facebook doesn't support add image any more, I decided to use Open Graph.

I succeeded to post with example source for the object type of "fitness.course", but still have troubles with the object type of "game.achievement".

Share Dialog shows up, and seems OK until I click post button. But, after clicking post button, I cannot find the post on my facebook wall.

Here is my source code.

    // Set image with the image on the file path
    Bitmap image = BitmapFactory.decodeFile(finalImageFilePath);
    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(image)
            .setUserGenerated(true)
            .build();

    // set object
    ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
            .putString("og:type", "game.achievement")
            .putString("og:title", "App Name")
            .putString("og:description", "You achieved Golden madal")
            .putInt("game:point", 100)
            .build();

    // set action
    ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
            .setActionType("games.achieves")
            .putObject("game.achievement", object)
            .putPhoto("image", photo)
            .build();

    // set content
    ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
            .setPreviewPropertyName("game.achievement")
            .setAction(action)
            .build();

    mShareDialog.show(content);

For your information, the below is the example source code I succeeded with

    // Set image with the image on the file path
    Bitmap image = BitmapFactory.decodeFile(finalImageFilePath);
    SharePhoto photo = new SharePhoto.Builder()
            .setBitmap(image)
            .setUserGenerated(true)
            .build();

    ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
           .putString("og:type", "fitness.course")
           .putString("og:title", "App Name")
           .putString("og:description", "You achieved Golden madal")
           .putInt("fitness:duration:value", 100)
           .putString("fitness:duration:units", "s")
           .putInt("fitness:distance:value", 12)
           .putString("fitness:distance:units", "km")
           .putInt("fitness:speed:value", 5)
           .putString("fitness:speed:units", "m/s")
           .build();

   ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
           .setActionType("fitness.runs")
           .putObject("fitness:course", object)
           .putPhoto("image", photo)
           .build();

   ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
           .setPreviewPropertyName("fitness:course")
           .setAction(action)
           .build();

Thanks a lot in advance for your efforts.

Ad

Answer

I think I have got the reason for this. It is so disappointing. Open Graph for game.achievement seems to have been depreciated. See the link https://developers.facebook.com/docs/games/services/scores-achievements?locale=en_US

The Scores API and Achievements API are slated for deprecation. As of April 4, 2018, they will only return empty data sets and will be deprecated in the near future. Please see the changelog for more information.

Also facebook depreciated Custom Open Graph. See the link https://developers.facebook.com/docs/sharing/opengraph/custom-open-graph-deprecation

Ad
source: stackoverflow.com
Ad