如何定义&"GeoPoint&"适用于iOS的Facebook SDK中的属性 [英] How to define a "GeoPoint" property in Facebook SDK for iOS

查看:44
本文介绍了如何定义&"GeoPoint&"适用于iOS的Facebook SDK中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过创建从预定义的地方"对象继承的Open Graph对象来对Open Graph故事进行地理标记.但是,我不知道如何在iOS中定义GeoPoint属性"place:location"!这里有一个类似问题的答案: https://stackoverflow.com/a/19386730/824515 尝试没有成功.

I'm trying to geo-tag an Open Graph story by creating an Open Graph object that inherits from the predefined "place" object. However, I can't figure out how to define the GeoPoint property "place:location" in iOS! There is an answer to a similar question here: https://stackoverflow.com/a/19386730/824515 which I have tried without success.

现在,我试图通过直接设置放置"对象来解决此问题,但这没有帮助.我收到此错误消息:

Now, I'm trying to break down the problem by setting up a "place" object directly, but it doesn't help. I get this error message:

error =         {
        code = 100;
        message = "(#100) Object Missing a Required Value: Object at URL '' of type 'place' is invalid because a required property 'place:location' of type 'geo_point' was not provided.";
        type = OAuthException;
    };

这是我的测试代码:

A:

FBRequestConnection *connection = [[[FBRequestConnection alloc] init] autorelease];
id<FBOpenGraphObject> object = [FBGraphObject openGraphObjectForPost];
object[@"type"] = @"place";
object[@"title"] = @"Test Title";

object[@"location"] = @{@"latitude": @"48.85831", @"longitude": @"2.29465"};

NSLog(@"object = %@", [object description]);
FBRequest *objectRequest = [FBRequest requestForPostOpenGraphObject: object];
[connection addRequest: objectRequest
     completionHandler: ^(FBRequestConnection *connection, id result, NSError *error) {
         DLine();
         if (error)
             NSLog(@"Error: %@", error);
         else
             NSLog(@"Result: %@", [result description]);
     }];
[connection start];

我尝试用我能想到的所有内容替换 object [@"location"] =…行,例如:

I have tried to replace the line object[@"location"] = … with everything I can think of, such as:

B:

object[@"place:location"] = @{@"latitude": @"48.85831", @"longitude": @"2.29465"};

C:

object[@"place"] = @{@"location":
                         @{@"latitude": @"48.85831", @"longitude": @"2.29465"}
                     };

D:

object[@"location:latitude"] = @"48.85831";
object[@"location:longitude"] = @"2.29465";

E:

object[@"place:location:latitude"] = @"48.85831";
object[@"place:location:longitude"] = @"2.29465";

对于所有版本A-E,错误消息都是相同的.

The error message was identical for all the versions A - E.

推荐答案

这对我有用:

NSMutableDictionary<FBOpenGraphObject> *store = [FBGraphObject openGraphObjectForPost];
store.provisionedForPost = YES;
store[@"og"] = @{ @"title":@"Test Title", @"type":@"place" };
store[@"place"] = @{ @"location" : @{ @"longitude": @"-58.381667", @"latitude":@"-34.603333"} };

[FBRequestConnection startForPostWithGraphPath:@"me/objects/place"
                                 graphObject:@{@"object":store}
                           completionHandler:^(FBRequestConnection *connection,
                                               id result,
                                               NSError *error) {
  if (!error) {
    NSLog(@"result: %@", result);
  }
  else {
    NSLog(@"%@", [NSString stringWithFormat:@"%@", error.description]);
  } 
}];

这篇关于如何定义&amp;"GeoPoint&amp;"适用于iOS的Facebook SDK中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆