健身的 Facebook 自定义单位未显示

Facebook custom unit for Fitness is not showing

我目前正在实施 Facebook Fitness 共享功能,我想拥有一个自定义单位,就像耐克所做的那样:

我托管了自己的单元对象并使用以下代码实现了共享按钮:

 iv_workout_share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

                    // Create an object
                    ShareOpenGraphObject.Builder object = new ShareOpenGraphObject.Builder()
                    .putString("fb:app_id", "xxxxx")
                    .putString("og:type", "fitness.course")
                    .putString("og:title", "example")

                    .putString("fitness:duration:value", (workout.duration / 1000) + "")
                    .putString("fitness:duration:units", "s")

                    .putString("fitness:distance:value", String.format("%.2f", workout.current_distance / 1000f))
                    .putString("fitness:distance:units", "km")

                    .putString("fitness:speed:value", (workout.current_distance / (workout.duration / 1000)) + "")
                    .putString("fitness:speed:units", "m/s")

                    .putString("fitness:custom_unit_energy:value", 100 + "")
                    .putString("fitness:custom_unit_energy:units", "http://example.com/fatburn.html");


            for (int i = 0; i < workout.location_record.size(); i++) {

                object.putDouble("fitness:metrics[" + i + "]:location:latitude", workout.location_record.get(i).getLat());
                object.putDouble("fitness:metrics["+i+"]:location:longitude",workout.location_record.get(i).getLong());

                if(i == 0) {
                    object.putString("fitness:metrics["+i+"]:timestamp", workout.timestamp - workout.duration + "");
                }else {

                    if (i == workout.location_record.size() - 1) {
                        object.putString("fitness:metrics["+i+"]:timestamp", workout.timestamp + "");
                    }
                }
            }

            // Create an action
            ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                    .setActionType("fitness.runs")
                    .putObject("course", object.build())
                    .build();

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


            ShareDialog shareDialog = new ShareDialog((Activity) context);
            shareDialog.show(content);
        }
    });

对于http://example.com/fatburn.html

<html>
<head>
<meta property="fb:app_id" content="381721038699445" /> 
<meta property="og:type"   content="fitness.unit" /> 
<meta property="og:url"    content="http://exanple.com/fatburn.html" /> 
<meta property="og:title"  content="Fat Burn" /> 
<meta property="og:image"  content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" /> 
<!-- Developer defined fitness unit name -->
<meta property="fitness:name" content="Fatburn"/>
</head>
<body>
</body>
</html>

当我点击分享按钮时,Facebook 分享对话框弹出,我按下 post 按钮,弹出提示框告诉我 post 已分享。

但是我的墙上什么都没有...

我的代码中是否漏掉了什么?

经过我的研究,我必须托管我自己的对象,就像我在更新 2 中所做的那样。

但它不起作用的原因是我的对象有问题。

我使用以下工具来验证对象并根据它给出的说明修复它,然后我的代码就可以工作了!

https://developers.facebook.com/tools/debug/