0

我想在 Facebook 上发布一个 Open Graph Fitness:runs 操作,并希望它使用我的路径图呈现。路径由下面的路径坐标定义。我该怎么做呢?下面的方法发布了操作,我可以在 Facebook 上的活动日志和时间轴中看到操作的文本。但是当我将鼠标悬停在已发布操作的任何元素上时,我看不到地图。我究竟做错了什么?

- (void) fbPost:(NSString *)txt toList:(NSString *)listId { // post

                [FBSession setActiveSession:[FacebookManager instance].facebook.session];



                NSMutableDictionary<FBGraphObject> *action = [FBGraphObject graphObject];
                action[@"course"] = @"http://samples.ogp.me/48586838281818";
                action[@"privacy"] = privacyStr;


                NSMutableArray *coords = [NSMutableArray arrayWithCapacity:59];
                for (int i = 0; i < 59; i++)
                {
                    NSMutableDictionary *coord = [[NSMutableDictionary alloc] initWithCapacity:3];

            #define TIMESTAMP @"fitness:metrics:timestamp"
            #define LATITUDE @"fitness:metrics:location:latitude"
            #define LONGITUDE @"fitness:metrics:location:longitude"
                    [coord setValue:[NSString stringWithFormat:@"2013-04-01T12:%2d:00+0000", i] forKey:TIMESTAMP];
                    [coord setValue:[NSString stringWithFormat:@"%f", 37.442564 + i * 0.00001] forKey:LATITUDE];
                    [coord setValue:[NSString stringWithFormat:@"%f", -122.164879 + i * 0.000001] forKey:LONGITUDE];
                    [coords addObject:coord];
                    NSLog(@"coord=%@ i=%d", coord, i);

                }

                action[@"path"] = [coords JSONString];
                action[@"message"] = txt;


                [FBRequestConnection startForPostWithGraphPath:@"me/fitness.runs"
                                                   graphObject:action
                                             completionHandler:^(FBRequestConnection *connection,
                                                                 id result,
                                                                 NSError *error) {
                                                 [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

                                                 if (!error) // it's a post, save id
                                                 {
                                                 }
                                                 else
                                                 {
                                                 }




                                             }];

            }
4

2 回答 2

1
NSMutableDictionary<FBGraphObject> *action = [FBGraphObject graphObject];
NSMutableDictionary<FBGraphObject> *course = [FBGraphObject openGraphObjectForPost];
course[@"og:title"] = @"My Workout";
course[@"og:type"] = @"fitness.course"; //very important
course[@"og:url"] = @"www.fitness.com"; // give a meaningful url here

course[@"fitness:duration:value"] = @"3000";
course[@"fitness:duration:units"] = @"s";

course[@"fitness:calories"] = @"100";

course[@"fitness:distance:value"] = 1.7;
course[@"fitness:distance:units"] = @"mi";

course[@"fitness:speed:value"] = @"2";
course[@"fitness:speed:units"] = @"m/s";

course[@"fitness:pace:value"] = @"0.5";
course[@"fitness:pace:units"] = @"s/m";
course[@"og:description"] = @"course_description";

NSMutableArray *locationDataPointsArray = [[NSMutableArray alloc] init];
locationDataPointsArray[0] = @{@"location:latitude": 12.91277, @"location:longitude": 77.56671};
locationDataPointsArray[1] = @{@"location:latitude": 12.91284, @"location:longitude": 77.56681};
locationDataPointsArray[2] = @{@"location:latitude": 12.91297, @"location:longitude": 77.56691};
course[@"fitness:metrics"] = locationDataPointsArray;

action[@"fb:explicitly_shared"] = @"true";
action[@"course"] = course;

NSString *path = @”me/fitness.runs”; 
//for custom story:    NSString *path = @”me/urNamespace:name of ur action”;


[FBRequestConnection startForPostWithGraphPath:path graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
    if (!error) {
        NSLog(@"Posted fitness action, id: %@", [result objectForKey:@"id"]);

        NSString *alertText = @"Workout successfully posted to Facebook  :)";
        NSString *alertTitle = @"Success";
        [[[UIAlertView alloc] initWithTitle:alertTitle message:alertText delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles:nil] show];
    }
    else {
                    NSLog(@"error in posting action  %@", error.description);

    }
}];
于 2014-06-05T10:30:54.390 回答
-1

我真的不知道如何回答您的问题,但是前几天我阅读了一些文件,它们可能对您有用...

我会推荐

您阅读了本文档,希望您能够了解如何将其集成到您的应用程序中。

您可能还想阅读this & this

快乐编码:)

于 2013-04-02T23:29:23.483 回答