How to add geolocation to a tweet in Rails?
At the moment my Rails app can tweet via twitter
gem, and I would like to add a geotag to my tweets. The geolocation is constant. How can I do this?
Twitter::Client.new.update('Hello, there!')
开发者_Python百科
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})
The user has to have checked the "Add a location to your tweets" option in their settings (aka geo_enabled)
Source: Twitter Gem API
精彩评论