I'm trying to share open graph stories and locations for a fitness course using facebook android sdk version 4.2,
I would like to have something like this:
https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xaf1/t39.2178-6/851557_504281972964839_1538874606_n.png
but the map does not show up
basically my code look like this:
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "fitness.course")
.putString("og:title", "Sample Course")
.putString("og:description", "This is a sample course.")
.putInt("fitness:duration:value", 100)
.putString("fitness:duration:units", "s")
.putInt("fitness:distance:value", 12)
.putString("fitness:distance:units", "km")
.putInt("fitness:speed:value", 5)
.putString("fitness:speed:units", "m/s");
ArrayList<ShareOpenGraphObject> metrics = new ArrayList<ShareOpenGraphObject>();
ShareOpenGraphObject.Builder metric1 = new ShareOpenGraphObject.Builder();
String timestamp1 = dateFormat.format(new Date(realDateTime1));
metric1.putDouble("fitness:metrics:location:latitude", latitude1);
metric1.putDouble("fitness:metrics:location:longitude",longitude1);
metric1.putString("fitness:metrics:timestamp",timestamp1);
metrics.add(metric1.build());
ShareOpenGraphObject.Builder metric2 = new ShareOpenGraphObject.Builder();
String timestamp2 = dateFormat.format(new Date(realDateTime2));
metric2.putDouble("fitness:metrics:location:latitude", latitude2);
metric2.putDouble("fitness:metrics:location:longitude",longitude2);
metric2.putString("fitness:metrics:timestamp",timestamp2);
metrics.add(metric2.build());
.....
object.putObjectArrayList("fitness:metrics", metrics);
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("fitness.runs")
.putObject("fitness:course", object.build())
.putString("fitness:start_time", startTime)
.putString("fitness:end_time", endTime)
.build();
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("fitness:course")
.setAction(action)
.build();
I did several tries without success, for example if I don't use the metrics array showed above and I put fitness:metrics:location:* directly on the original object builder the map is shown with a single location. Hints?
I had a similar issue, in my case I had a web backend that host the fitness course and I solved it by setting in the ShareOpenGrapAction the url of the fitness course.
In the web backend the fitness course is created using the reference stated here: https://developers.facebook.com/docs/opengraph/guides/fitness
In the app
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("fitness.runs")
.putString("fitness:course", url)
.build();
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("fitness:course")
.setAction(action)
.build();
Than call the show
if (shareDialog.canShow(ShareOpenGraphContent.class)) {
shareDialog.show(content);
}
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With