【问题标题】:iOS Facebook Status LocationiOS Facebook 状态位置
【发布时间】: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];
}

【问题讨论】:

    标签: ios facebook location


    【解决方案1】:

    creating a stream post 的文档列出了一个参数 place,其值为 该位置的 Facebook 页面 ID。您可以通过searchquerying the place FQL table 找到这些地点ID。

    在这种情况下,您还应该使用 Graph api 路径 me/feed

    虽然与您的问题无关,但在 if (image) 分支中添加了一个参数 type,该参数未在 section on posting a photo 中记录。

    【讨论】:

      【解决方案2】:

      要添加地点,您需要提供 Facebook 目前已知的地点 ID。为此,您可以获取返回 ID 的最近地点,然后添加您想要的地点作为地点。

      【讨论】:

        【解决方案3】:

        你错过了一些东西,我记得,hackbook 使用位置来查找地点 id,然后将其放入参数“地点”中。

        为此, 1.你需要做一个搜索:

        https://graph.facebook.com/search?
          q=coffee&
          type=place&
          center=40.7167,-74&
          distance=1000
        

        //从facebook复制:]

        1. 选择一个地点
        2. 发布带有地点 ID 的帖子 请注意,正如我之前尝试过的那样,您无法选择距离超过 1000m 的地方 (现在不确定,很久以前尝试过)

        【讨论】:

          【解决方案4】:

          要对此进行测试,您可以在这里尝试https://developers.facebook.com/tools/ 在字段中粘贴此行示例“search?q=spa&type=place&center=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,然后添加“消息”和“地点”的字段参数进行测试。

          【讨论】:

            猜你喜欢
            • 2015-06-05
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2012-10-21
            • 1970-01-01
            • 1970-01-01
            • 2012-10-13
            相关资源
            最近更新 更多