我正在开发一个 android 健身应用程序,我可以通过我的 android 应用程序将距离、持续时间或卡路里等课程详细信息发送到 facebook,但我无法发送数据点位置列表以在我的时间线状态上绘制地图,我使用了为此目的以下代码:
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");
course.getData().setProperty("distance:value", 2.5f);
course.getData().setProperty("distance:units", "km");
course.getData().setProperty("duration:value", 1800.0f);
course.getData().setProperty("duration:units", "s");
course.getData().setProperty("speed:value", 3.0f);
course.getData().setProperty("speed:units", "m/s");
int[] cals = {50,70};
course.getData().setProperty("metrics:calories",cals);
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());
}
}
运行此代码后,我得到了异常:
com.facebook.facebookexception: failed to generate preview for user.