我正在开发一个 Android 健身应用程序,我正在尝试使用 Open Graph API 在 Facebook 上发布活动数据点位置。我使用了以下代码,它只发布了location1
,但没有添加到列表中的其他位置。
public void shareWorkout (View v){
if (FacebookDialog.canPresentShareDialog(getApplicationContext(), FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
OpenGraphObject course = OpenGraphObject.Factory.createForPost(null);
course.setType("fitness.course");
course.setTitle("Walking Course");
course.setUrl("http://samples.ogp.me/136756249803614");
course.setDescription("walked a course");
GraphObject location1 = GraphObject.Factory.create();
location1.setProperty("latitude", 31.90592568833381f);
location1.setProperty("longitude", 35.20052916370332f);
location1.setProperty("altitude", 0.0f);
GraphObject location2 = GraphObject.Factory.create();
location2.setProperty("latitude", 31.912331976927817f);
location2.setProperty("longitude", 35.205821581184864f);
location2.setProperty("altitude", 0.0f);
List<GraphObject> locations = new ArrayList<GraphObject>();
locations.add(location1);
locations.add(location2);
GraphObject metrics = GraphObject.Factory.create();
metrics.setProperty("location", locations);
course.getData().setProperty("metrics", metrics);
OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
action.setProperty("course", course);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this,
action, "fitness.walks", "course").build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
}