【问题标题】:How to geocode a Twitter status update using the Ruby OAuth Gem如何使用 Ruby OAuth Gem 对 Twitter 状态更新进行地理编码
【发布时间】:2011-08-12 12:44:01
【问题描述】:

使用以下 Ruby 代码,我可以通过 Twitter API 向我的帐户发送状态更新。根据Twitter API Docs,我希望它被地理编码,但事实并非如此。我做错了什么?

require 'oauth'
consumer = OAuth::Consumer.new('<MY_CONSUMER_KEY>', '<MY_CONSUMER_SECRET>', :site => "http://api.twitter.com", :scheme => :header)
access_token = OAuth::AccessToken.from_hash(consumer, :oauth_token => '<MY_OAUTH_TOKEN>', :oauth_token_secret => '<MY_OAUTH_SECRET>')
access_token.request(:post, "http://api.twitter.com/1/statuses/update.xml", {"Content-Type" => "application/xml", "status" => "This Tweet is from Zuerich in Switzerland", "lat" => "47.3807", "long" => "8.537", "display_coordinates" => "true", "geo_enabled" => "true"}) 

【问题讨论】:

  • 对我来说没问题。你的 Twitter 个人资料设置中是否启用了“为你的推文添加位置”?
  • @nash:非常感谢,这就是解决方案! :)
  • @nash:把它放在答案中,我很乐意接受。

标签: ruby twitter geocoding twitter-oauth


【解决方案1】:

它工作正常。您应该在您的推特个人资料设置中启用"Add a location to your tweets"

【讨论】:

    猜你喜欢
    • 2011-02-13
    • 2012-01-14
    • 1970-01-01
    • 2015-06-22
    • 2012-11-06
    • 2013-06-08
    • 2012-08-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多