San*_*ian 2 android facebook-graph-api facebook-android-sdk facebook-opengraph facebook-share
当玩家解锁徽章时,我正在努力实现分享到Facebook的成就.在facebook开发者控制台中使用对象浏览器创建了一个对象.我制作了动作类型和对象类型并制作了一个自定义故事.现在我被困在试图分享到Facebook的故事.facebook提供的文件不足.甚至facebook提供的示例代码也使用v3.x.
facebook给出的示例代码如下.无法找到任何好的文档.
对象代码
Bundle params = new Bundle();
Request request = new Request(
Session.getActiveSession(),
"me/objects/enguru_app:badge",
params,
HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response
Run Code Online (Sandbox Code Playgroud)
行动守则
Bundle params = new Bundle();
params.putString("badge", "http://samples.ogp.me/1114467558579559");
Request request = new Request(
Session.getActiveSession(),
"me/enguru_app:unlocked",
params,
HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response
Run Code Online (Sandbox Code Playgroud)
最后想出了我自己的问题.
这是解决方案:
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "enguru_app:badge")
.putString("og:title", "Unlocked Newbie Badge")
.putString("og:url","xxxx")
.putString("og:image","xxx")
.putString("game:points", "10")
.putString("fb:app_id", "xxx")
.putString("og:description",
"We are rocking. Come and Play with us").build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("enguru_app:unlocked")
.putObject("badge", object).build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("badge").setAction(action)
.build();
ShareDialog.show(Profile.this, content);
Run Code Online (Sandbox Code Playgroud)
我希望这能帮助那些经历同样问题的人.
| 归档时间: |
|
| 查看次数: |
2739 次 |
| 最近记录: |