【发布时间】:2012-02-24 07:12:54
【问题描述】:
我对如何在用户状态中使用位置感到困惑。我看到有一个地方字段,但我不知道如何使用它。指令只是说一个对象,它根本没有指定它想要什么对象以及它想要什么格式。谁能帮我发布一个带有位置的状态?
这是我现在的代码:
- (void)postWithMessage:(NSString *)message image:(UIImage *)image location:(CLLocation *)location {
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSString *path = @"feed";
[params setObject:@"status" forKey:@"type"];
if (message && ![message isEqualToString:@""]) [params setObject:message forKey:@"message"];
if (image) {
path = @"me/photos";
[params setObject:@"photo" forKey:@"type"];
NSData *imageData = UIImagePNGRepresentation(image);
[params setObject:imageData forKey:@"source"];
}
if (location) {
//Stole this from iOS hackbook that Facebook wrote, but it wasn't helpful.
NSString *centerLocation = [[NSString alloc] initWithFormat:@"%f,%f", location.coordinate.latitude, location.coordinate.longitude];
[params setObject:centerLocation forKey:@"center"];
}
[facebook requestWithGraphPath:path andParams:params andHttpMethod:@"POST" andDelegate:self];
}
【问题讨论】: