Facebook健身开放图故事,地图和路线在地图上

时间:2015-07-22 06:12:56

标签: php android ios facebook facebook-opengraph

我正在尝试创建健身运行故事。我可以用距离,持续时间,卡路里等信息发布故事,但无法将地图显示为endomondo,nike running,runkeeper应用程序正在进行。

enter image description here

Nike +正在运行的应用程序显示健身运行信息

enter image description here

我的应用程序显示运行信息:(

我还尝试使用新动作和对象创建自定义开放图形故事,但这对我也不起作用。有没有人知道如何在iOS或PHP方面做到这一点?

1 个答案:

答案 0 :(得分:0)

这是使用map& amp;创建健身运行故事的代码。 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];