Tôi bị nhầm lẫn về cách tôi sử dụng vị trí trong trạng thái của người dùng. Tôi thấy có một trường địa điểm, nhưng tôi không biết cách sử dụng nó. Các hướng dẫn chỉ nói một đối tượng, nó không chỉ định ở tất cả các đối tượng mà nó muốn và ở định dạng nào nó muốn. Bất cứ ai có thể cho tôi một bàn tay trên gửi một tình trạng với một vị trí trên đó?Trạng thái Facebook iOS Vị trí
Đây là mã của tôi bây giờ:
- (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];
}