【发布时间】: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