如何使用 Ruby OAuth Gem 对 Twitter 状态更新进行地理编码
使用以下 Ruby 代码,我可以通过 Twitter API 将状态更新发送到我的帐户。根据 Twitter API 文档 我希望它能被地理编码,但事实并非如此't。我做错了什么?
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"})
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" => "true"})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
工作正常。您应该在 Twitter 个人资料设置中启用
“向您的推文添加位置”
。It works ok. You should enable
"Add a location to your tweets"
in your twitter profile settings.