开发者

How to geocode a Twitter status update using the Ruby OAuth Gem

开发者 https://www.devze.com 2023-02-28 09:47 出处:网络
Using the following Ruby code, I can send a status update over the Twitter API to my account. According to the Twitter API Docs I would expect it to be geocoded, but it isn\'t. What am I doing wrong?

Using the following Ruby code, I can send a status update over the Twitter API to my account. According to the Twitter API Docs I would expect it to be geocoded, but it isn't. What am I doing wrong?

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" => "tr开发者_如何学JAVAue"}) 


It works ok. You should enable "Add a location to your tweets" in your twitter profile settings.

0

精彩评论

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