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

あなたの質問にどう答えたらいいのかよくわかりませんが、先日いくつかの文書を読みましたが、それらはあなたにとって役立つかもしれません...

私がお勧めします

このドキュメントを読んで、アプリにこれを統合する方法を理解していただければ幸いです。

これこれを読むこともできます

ハッピーコーディング:)

于 2013-04-02T23:29:23.483 に答える