简体   繁体   中英

Posting a map to Facebook using Facebook SDK from iOS

I am posting an image to facebook through FBRequestConnection. How can I post a map to FB by giving a latitude and longitude. (Also attaching some text with this) Please advise.

   if (FBSession.activeSession.isOpen) {


        NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
        [params setObject:@"Posting from padivattom" forKey:@"message"];
        [params setObject:UIImagePNGRepresentation(image) forKey:@"picture"];

        [FBRequestConnection startWithGraphPath:@"me/photos"
                                     parameters:params
                                     HTTPMethod:@"POST"
                              completionHandler:^(FBRequestConnection *connection,
                                                  id result,
                                                  NSError *error)
         {
             if (error)
             {
                 //showing an alert for failure

             }
             else
             {
                 //showing an alert for success

             }
          }];

I used the method:

[FBWebDialogs presentFeedDialogModallyWithSession:
                                       parameters:
                                          handler:

to post message and map to facebook. (Its post to news feed).

But you can try to add to your dictionary: [params setObject:[NSString stringWithFormat:@" https://maps.google.com/?q=%@,%@ ",latitude,longitude] forKey:@"link"];

(If it doesn't work, you can find the Feed Dialog sample on facebook developers page).

I hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM