如何 post 通过 Facebook Open Graph 进行游戏
How to post through Facebook Open Graph for game
我正在开发一些问答应用程序,想 post 玩家在 facebook 上的成就。
因为我想post成就的图片和LinkFacebook的分享不再支持添加图片,所以我决定使用Open Graph。
我使用 "fitness.course" 对象类型的示例源成功 post,但在 "game.achievement" 对象类型方面仍然存在问题。
共享对话框出现,在我单击 post 按钮之前似乎没问题。但是,在点击 post 按钮后,我在我的 facebook 墙上找不到 post。
这是我的源代码。
// 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);
为了您的信息,下面是我成功的示例源代码
// 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();
非常感谢您的努力。
我想我已经找到了原因。太令人失望了。 game.achievement 的 Open Graph 似乎已贬值。见 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.
Facebook 还贬低了 Custom Open Graph。见 link https://developers.facebook.com/docs/sharing/opengraph/custom-open-graph-deprecation
我正在开发一些问答应用程序,想 post 玩家在 facebook 上的成就。
因为我想post成就的图片和LinkFacebook的分享不再支持添加图片,所以我决定使用Open Graph。
我使用 "fitness.course" 对象类型的示例源成功 post,但在 "game.achievement" 对象类型方面仍然存在问题。
共享对话框出现,在我单击 post 按钮之前似乎没问题。但是,在点击 post 按钮后,我在我的 facebook 墙上找不到 post。
这是我的源代码。
// 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);
为了您的信息,下面是我成功的示例源代码
// 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();
非常感谢您的努力。
我想我已经找到了原因。太令人失望了。 game.achievement 的 Open Graph 似乎已贬值。见 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.
Facebook 还贬低了 Custom Open Graph。见 link https://developers.facebook.com/docs/sharing/opengraph/custom-open-graph-deprecation