android - Facebook custom unit for Fitness is not showing -
i implementing facebook fitness sharing feature , have custom unit nike do:
i have hosted own unit object , implemented share button using following code:
iv_workout_share.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // create 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"); (int = 0; < workout.location_record.size(); i++) { object.putdouble("fitness:metrics[" + + "]: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 action shareopengraphaction action = new shareopengraphaction.builder() .setactiontype("fitness.runs") .putobject("course", object.build()) .build(); // create content shareopengraphcontent content = new shareopengraphcontent.builder() .setpreviewpropertyname("course") .setaction(action) .build(); sharedialog sharedialog = new sharedialog((activity) context); sharedialog.show(content); } });
and 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>
and when click share button, facebook share dialog pop , press post button, toast pop telling me post shared.
but nothing show on wall...
did missed in code?
after research, have host own object, did in update 2.
but reason not working have wrong in object.
i use following tool validate object , fix according instruction gives, code works!
Comments
Post a Comment