2011-04-25 18 views
0

使用以下Ruby代碼,我可以通過Twitter API向我的帳戶發送狀態更新。根據Twitter API Docs我希望它是地理編碼,但事實並非如此。我究竟做錯了什麼?如何使用Ruby OAuth Gem對Twitter狀態更新進行地理編碼

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"}) 
+1

它適用於我。是在您的Twitter個人資料設置中啓用「向您的推文添加位置」? – 2011-04-25 20:34:37

+0

@nash:非常感謝,那就是解決方案! :) – Javier 2011-04-25 22:12:40

+0

@nash:把它放在答案中,我會很樂意接受它。 – Javier 2011-04-25 22:40:28

回答

1

它工作正常。您應該在您的twitter配置文件設置中啓用"Add a location to your tweets"

相關問題