使用Facebook的开放图谱发布图文分享

Android 平台中的开放图谱动态:https://developers.facebook.com/docs/sharing/opengraph/android

Object Types 和 Action Types:https://developers.facebook.com/docs/reference/opengraph

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
private void shareBargainOrder() {
// Create an object
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "article")
.putString("og:url", mBargainOrder.getInviteUrl())
.putString("og:title", mBargainGoods.getName())
.putString("og:description", mBargainGoods.getDescription())
.putString("og:image", mBargainGoods.getPicUrl())
.putString("fb:app_id", mResources.getString(R.string.facebook_app_id))
.build();

// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("news.publishes")
//.setActionType("news.reads")
.putObject("article", object)
.build();

// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("article")
.setAction(action)
.build();

if (ShareDialog.canShow(ShareLinkContent.class)) {
mShareDialog.show(content);
} else {
ShareApi.share(content, mFacebookCallback);
}
}

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :