Pradeep
Pradeep

Reputation: 563

How to use Facebook Open graph api for fitness for walking through FacebookSDK

I want to publish an Open Graph fitness:walk action on Facebook and I want it to render with a map of my path. How do I do this? The method below publishes the action and I can see the text for the action in my Activity Log on Facebook and in my timeline. But I do not see a map when I hoover over any element of the posted action. What am I doing wrong?

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

[FBRequestConnection startForPostWithGraphPath:@"me/fitness.walks"
                                   graphObject:action
                             completionHandler:^(FBRequestConnection *connection,
                                                 id result,
                                                 NSError *error) {
                                 // handle the result
                                 NSLog(@"error:%@",error.description);

                                 NSLog(@"Result:%@",result);
                             }];

Upvotes: 4

Views: 1189

Answers (1)

Hardik rami
Hardik rami

Reputation: 341

Try this

   [FBRequestConnection startForPostWithGraphPath:[NSString stringWithFormat:@"me/fitness.%@?access_token=%@",walkType,appDelegate.session.accessTokenData.accessToken]
                                       graphObject:action
                                 completionHandler:^(FBRequestConnection *connection,
                                                     id result,
                                                     NSError *error)
                                {
                                     // handle the result
                                     //NSLog(@"error description:%@",error);
                                     NSLog(@"Result:%@",result);
                                     [SVProgressHUD dismiss];
                                    if (error == nil)
                                    {
                                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Track My Walks" message:[NSString stringWithFormat:@"You successfully post a route and your id is:%@",[result valueForKey:@"id"]] delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
                                        [alert show];
                                    }
                                    else
                                    {
                                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Track My Walks" message:error.description delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
                                        [alert show];
                                    }

                                 }];
}];
[request setFailedBlock:^{
    [SVProgressHUD dismiss];
    NSError *error = [request error];
    NSLog(@"Error: %@", error.localizedDescription);
    [self directionsDidFailedDirections:error.localizedDescription];
}];

[request startAsynchronous];

Upvotes: 1

Related Questions