照片上传到自己的墙上通过iOSgraphicsAPI与用户的位置

我需要在用户的位置用户的facebook墙壁张贴照片(从相机拍摄)。 现在,Facebook的照片对象有一个名为地方的字段:

object containing id and name of Page associated with this location, and a location field containing geographic information such as latitude, longitude, country, and other fields (fields will vary based on geography and availability of information) 

现在我怎样才能find这个地方,把它附在照片上,然后上传到用户墙上。 这是我的照片上传代码:

 NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: resultImage, @"picture", location, @"place", nil]; [appDelegate.facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

但是,如何获取位置参数呢? 谁能帮忙? 提前致谢。

根据本文档 ,地点对象只能是所需位置的Facebook页面标识。 所以,这里是我如何设法获取用户的位置,而上传照片。

 -(void)fbCheckForPlace:(CLLocation *)location { NSString *centerLocation = [[NSString alloc] initWithFormat:@"%f,%f", location.coordinate.latitude, location.coordinate.longitude]; NSLog(@"center location is : %@",centerLocation); NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"place", @"type", centerLocation, @"center", @"1000", @"distance", nil]; [centerLocation release]; [appDelegate.facebook requestWithGraphPath:@"search" andParams:params andDelegate:self]; } 

通过调用CLLocation Manager委托并通过上述方法传递当前位置。

接下来,如果该请求成功,则将地点对象插入到可变数组中。

 NSArray *resultData = [result objectForKey:@"data"]; for (NSUInteger i=0; i<[resultData count] && i < 5; i++) { [self.listOfPlaces addObject:[resultData objectAtIndex:i]]; } 

然后照片上传方法被激发:

 - (void)uploadPhotoWithLocation { NSString *placeId = [[self.listOfPlaces objectAtIndex:0] objectForKey:@"id"]; params = [NSMutableDictionary dictionaryWithObjectsAndKeys: self.resultImage, @"picture", placeId, @"place", nil]; [appDelegate.facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self]; } 

我已经采取了可用的检查( [self.listOfPlaces objectAtIndex:0] )附近的第一个位置,现在应用程序可以成功地发布照片与用户当前附近的位置。

FB API显示:'place':'包含与该位置关联的页面的id和名称的对象,以及包含诸如纬度,经度,国家和其他字段的地理信息的位置字段(字段将根据地理位置和可用性信息)'

1)在iOS 2中启动位置服务)获取当前位置:经度,纬度

使用两个数据的纬度,经度

Shabib上面的答案很好(我没有足够的代表直接发表评论),但是现在您还需要指定“fields”参数,以便图表请求成功完成/ search。 我的参数字典看起来像这样:

 NSDictionary *params = @{@"type" : @"place", @"center" : centerLocation, @"distance" : @"500", @"fields" : @"id,name"};