开发者

How to add geolocation to a tweet in Rails?

开发者 https://www.devze.com 2023-02-23 08:12 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消