[英]Facebook fitness open graph story with map and route on Map
我正在尝试创建健身跑步故事。 我可以发布有关距离,持续时间,卡路里等信息的故事,但无法显示地图,如Endmondo,耐克跑步,runkeeper应用程序正在执行的操作。
Nike + Running App显示健身跑步信息
我的应用显示运行信息:(
我还尝试用新的动作和对象创建自定义的开放图故事,但这对我也不起作用。 有谁知道如何在iOS或PHP方面做到这一点?
这是在Facebook上使用地图和折线创建健身跑步故事的代码。
NSMutableDictionary *dictonary = [[NSMutableDictionary alloc] init];
[dictonary setObject:@"fitness.course" forKey:@"og:type"];
[dictonary setObject:@"Name which you want to share" forKey:@"og:title"];
[dictonary setObject:@"A url which will be open on click" forKey:@"og:url"];
[dictonary setObject:@"set description like you ran 5km in 40 min" forKey:@"og:description"];
//duration of the activity
[dictonary setObject:@"2400" forKey:@"fitness:duration:value"];
//time unit, s stands for seconds
[dictonary setObject:@"s" forKey:@"fitness:duration:units"];
//distance of the activity
[dictonary setObject:@"5" forKey:@"fitness:distance:value"];
//distance unit in KM
[dictonary setObject:@"km" forKey:@"fitness:distance:units"];
//speed distance in meter / time in seconds
[dictonary setObject:@(distance/speed) forKey:@"fitness:speed:value"];
[dictonary setObject:@"m/s" forKey:@"fitness:speed:units"];
//here adding lat lngs in the request for show map on facebook activity
int i=0;
for (NSDictionary *location in locationArray) {
CLLocation *loc=[[CLLocation alloc] initWithDictionary:location];
[dictonary setObject:[NSNumber numberWithDouble:loc.coordinate.latitude] forKey:[NSString stringWithFormat:@"fitness:metrics[%d]:location:latitude",i]];
[dictonary setObject:[NSNumber numberWithDouble:loc.coordinate.longitude] forKey:[NSString stringWithFormat:@"fitness:metrics[%d]:location:longitude",i]];
i++;
}
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:dictonary];
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"fitness.runs";
[action setObject:object forKey:@"fitness:course"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"fitness:course";
[FBSDKShareDialog showFromViewController:self withContent:content delegate:self];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.