2013-04-02 61 views
0

我想在Facebook上發佈Open Graph fitness:runs操作,我希望它可以用我的路徑地圖進行渲染。路徑由下面的路徑座標定義。我該怎麼做呢?下面的方法發佈了該操作,我可以在我的Facebook上的活動日誌和時間軸中看到該操作的文本。但是,當我對發佈的操作的任何元素進行回顧時,我沒有看到地圖。我究竟做錯了什麼?如何使用iOS SDK發佈包含地圖的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 
               { 
               } 




              }]; 

      } 
+0

你能解決這個讀?我也嘗試用座標發佈FB Graph動作。 –

回答

-1

我真的不知道怎麼回答你的問題,但是我看了一些文件有一天,他們可能對你有用...

我會建議

那你需要閱讀this document,並希望你能夠理解如何將它集成到你的應用中。

您可能還需要採取的this & this

編碼愉快:)

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); 

    } 
}]; 
相關問題