问题描述
我正在开发一些测验应用程序,并想在Facebook上发布玩家的成就.
I am developing some quiz app, and want to post player's achievement on facebook.
由于我要发布成就图片,而Facebook的Link Share不再支持添加图片,因此我决定使用Open Graph.
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.
我成功地用示例源发布了"fitness.course"对象类型,但是仍然对"game.achievement"对象类型感到烦恼.
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".
出现共享对话框",并且在单击发布"按钮之前似乎没有问题.但是,单击发布按钮后,我无法在我的Facebook墙上找到该帖子.
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.
这是我的源代码.
// 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();
非常感谢您的努力.
推荐答案
我认为我有这个理由.真令人失望. game.achievement的Open Graph似乎已被贬值.请参阅链接 https://developers.facebook.com/docs /games/services/scores-achievements?locale = zh_CN
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
facebook也贬值了Custom Open Graph.请参阅链接 https://developers.facebook.com/docs /sharing/opengraph/custom-open-graph-deprecation
Also facebook depreciated Custom Open Graph. See the link https://developers.facebook.com/docs/sharing/opengraph/custom-open-graph-deprecation
这篇关于如何通过Facebook Open Graph发布游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!