English 中文(简体)
Fourquare API 解释结果
原标题:Foursquare API Interpreting Results

我试图用四平方API 建立一个小应用程序。

require  rubygems 
require  rest-client 
require  json 
require  foursquare2 
require  awesome_print 

client = Foursquare2::Client.new(:client_id =>  xxx , :client_secret =>  xxx )

response = client.search_venues(:ll =>  36.142064,-86.816086 , :query =>  nails )

不过我从API得到的反应却令人费解!

[
    [0] "groups",
    [1] [
        [0] {
             "type" => "places",
             "name" => "Places",
            "items" => [
                [ 0] {
                            "id" => "4e24ce97fa76c80b5f5adfcc",
                          "name" => "The Nail Spa",
                       "contact" => {
                                 "phone" => "6152975895",
                        "formattedPhone" => "(615) 297-5895"
                    },
                      "location" => {
                            "address" => "2126 Abbot Martin Rd. Suite 102",
                        "crossStreet" => "at Green Hills Mall",
                                "lat" => 36.10713765714286,
                                "lng" => -86.817004,
                           "distance" => 3888,
                         "postalCode" => "37215",
                               "city" => "Nashville",
                              "state" => "TN",
                            "country" => "United States"
                    },
                    "categories" => [
                        [0] {
                                    "id" => "4bf58dd8d48988d10c951735",
                                  "name" => "Cosmetics Shop",
                            "pluralName" => "Cosmetics Shops",
                             "shortName" => "Beauty / Cosmetic",
                                  "icon" => "https://foursquare.com/img/categories/shops/beauty_cosmetic.png",
                               "parents" => [
                                [0] "Shops & Services"
                            ],
                               "primary" => true
                        }
                    ],
                      "verified" => false,
                         "stats" => {
                        "checkinsCount" => 103,
                           "usersCount" => 90,
                             "tipCount" => 5
                    },
                      "specials" => []
                },

以上是答复的第一部分,许多数据都回来了。

Ruby拿出你想要的分数的最佳方法是什么?例如,如果我要每个结果的名字回来的话?

回应的类别是Hashie:我以前从未见过的马什?

最佳回答

哈希给你一些糖 与哈希斯玩(见https://github.com/intrida/hashie )。

要获得每个结果的名称, 类似的东西应该可以做这个把戏:

response.groups[0].items.each{|i| puts i.name}
问题回答

暂无回答




相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签