我对如何使用用户状态中的位置感到困惑。我看到有一个位置字段,但我不知道如何使用它。指令只是说了一个对象,它根本没有指定它想要什么对象以及它想要什么格式。有没有人可以帮我张贴一个有位置的状态?
这是我现在的代码:
- (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];
}
发布于 2012-08-31 15:27:34
添加地点时,需要提供Facebook目前已知的地点ID。为此,您可以获取最近的位置,它也返回ID,然后添加您想要的位置作为位置。
发布于 2013-01-24 17:14:12
要测试这一点,您可以尝试在此处,在字段中粘贴此行示例"search?q=spa&type=place¢er=40.7167,-74& distance=1000“
then you will see results like
{
"data": [
{
"location": {
"street": "221 Canal Street, Room 301",
"city": "New York",
"state": "NY",
"country": "United States",
"zip": "10013",
"latitude": 40.71761,
"longitude": -73.99933
},
"category": "Spas/beauty/personal care",
"name": "CiCi Beauty Spa",
"id": "180068255444372"
},
etc...
you can then post status like
("message", "im here guys"); // your message
("place", "180068255444372"); // the id of the place
in the tool field "me/feed"
在工具中,将方法更改为POST,然后为"message“和"place”添加字段参数以测试它。
https://stackoverflow.com/questions/9098660
复制相似问题