如何将地理位置添加到Rails中的推文中?

问题描述:

目前我的Rails应用程序可以通过twitter gem发布消息,并且我想向我的推文添加地理标记。地理位置是恒定的。我怎样才能做到这一点?如何将地理位置添加到Rails中的推文中?

Twitter::Client.new.update('Hello, there!') 

Twitter.configure do |config| 
    config.consumer_key = YOUR_CONSUMER_KEY 
    config.consumer_secret = YOUR_CONSUMER_SECRET 
    config.oauth_token = YOUR_OAUTH_TOKEN 
    config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET 
end 

# Initialize your Twitter client 
client = Twitter::Client.new 

# Post a status update 
client.update("I just posted a status update via the Twitter Ruby Gem!", {:lat => 38.89859, :long => -77.035971}) 

用户必须已经检查选项 “到你的微博添加位置”,在他们的设置(又名geo_enabled)

Source: Twitter Gem API