Facebook 健身开放图故事,地图上有地图和路线
Facebook fitness open graph story with map and route on Map
我正在努力创造健身 运行 的故事。我能够 post 包含距离、持续时间、卡路里等信息的故事,但无法像 endomondo、nike 运行ning、运行keeper 应用程序那样显示地图。
Nike+ 运行ning 应用显示健身 运行 信息
我的应用程序显示 运行 信息 :(
我还尝试使用新的动作和对象创建自定义开放图故事,但这对我也不起作用。有谁知道如何在 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];
我正在努力创造健身 运行 的故事。我能够 post 包含距离、持续时间、卡路里等信息的故事,但无法像 endomondo、nike 运行ning、运行keeper 应用程序那样显示地图。
Nike+ 运行ning 应用显示健身 运行 信息
我的应用程序显示 运行 信息 :(
我还尝试使用新的动作和对象创建自定义开放图故事,但这对我也不起作用。有谁知道如何在 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];