我一直在尝试使用twitter-omniauth
gem 验证用户的最后几天,但没有成功.(与facebook的身份验证工作完美)
我一直在收到401 Unauthorized错误.
我搜索stackoverflow,但没有一个答案可以解决我的问题.
我尝试时到达Twitter登录http://127.0.0.1/users/auth/twitter
.我登录后,我被重定向到http://127.0.0.1/users/auth/twitter/callback
未经授权的错误.
我在twitter中输入了回调网址
http://127.0.0.1/users/auth/twitter/callback
rake routes
产量
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_omniauth_callback /users/auth/:action/callback(.:format) {:action=>/twitter|facebook/, :controller=>"users/omniauth_callbacks"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"devise/registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE …
Run Code Online (Sandbox Code Playgroud) 我在那里找到了几个不同的twitter gem(用于ruby-on-rails):
http://twitter4r.rubyforge.org/
但我想知道是否有人可以评价他们并提供一个或一个新的建议.
谢谢
参数的格式应该是什么:media
在下面的调用中,用于更新多个图像.
def twitter_status_update_with_media (twitter_client, text, media, opts)
twitter_client.update_with_media(self.text, media, opts)
end
Run Code Online (Sandbox Code Playgroud)
对于单个图像,File.new(filepath)
工作正常..
这可能是一个非常简单的问题,但我无法弄清楚如何呈现嵌入式推文.
为简单起见,这是我的控制器:
class TweetsController < ApplicationController
def index
@tweet = twitter_client.oembed('527501479142109184')
end
end
Run Code Online (Sandbox Code Playgroud)
在视图中,如果我只是执行以下操作,它仅显示对象:
<%= @tweet %>
Run Code Online (Sandbox Code Playgroud)
即 #<Twitter::OEmbed:0x007fb878abc5d8>
在检查时,这给出:
#<Twitter::OEmbed:0x007fb875cacd28 @attrs={:cache_age=>"3153600000", :url=>"https://twitter.com/HuayuanSong/statuses/527501479142109184", :height=>nil, :provider_url=>"https://twitter.com", :provider_name=>"Twitter", :author_name=>"Huayuan Song", :version=>"1.0", :author_url=>"https://twitter.com/HuayuanSong", :type=>"rich", :html=>"<blockquote class=\"twitter-tweet\"><p>Jeg kunne lide en video på <a href=\"https://twitter.com/YouTube\">@YouTube</a> <a href=\"http://t.co/hhhTvyJA6y\">http://t.co/hhhTvyJA6y</a> Obama: U.S. leading the way against Ebola spread</p>— Huayuan Song (@HuayuanSong) <a href=\"https://twitter.com/HuayuanSong/status/527501479142109184\">October 29, 2014</a></blockquote>\n<script async src=\"//platform.twitter.com/widgets.js\" charset=\"utf-8\"></script>", :width=>550}>
Run Code Online (Sandbox Code Playgroud)
显然,这非常简单,我只是使用这个概念证明类型的东西.有人可以解释我如何从拥有该对象到能够显示实际的嵌入式推文?
谢谢
我有一个来自twitter gem的 Tweet 对象,名为@tweet
.
我能够做到:
\n\n@tweet.created_at --> `@tweet.created_at.class` outputs `Time`\n
Run Code Online (Sandbox Code Playgroud)\n\n但是,我想更改 的时区created_at
,所以我尝试了:
@tweet.created_at.utc\n
Run Code Online (Sandbox Code Playgroud)\n\n并得到:
\n\ncan\'t modify frozen Time\n
Run Code Online (Sandbox Code Playgroud)\n\n我如何从当前的 UTC\xe2\x88\x9208:00 更改created_at
为 CET 时间?
如何使用twitter gem执行此调用?
我试过了:
client.search('sachin')
Run Code Online (Sandbox Code Playgroud)
但那只Twitter::SearchResults
包含推文的返回.
我有一个Twitter :: Tweet的实例,它没有转发方法.(http://www.rubydoc.info/gems/twitter/Twitter/Tweet)
但是,Twitter :: REST :: Tweets确实有一个我可以用来转推的方法.(http://www.rubydoc.info/gems/twitter/Twitter/REST/Tweets#retweet-instance_method)
我找不到一个例子:https://github.com/sferik/twitter
任何帮助赞赏.我可能只是太晚才把它弄清楚了.
干杯,伊恩.
我正在使用twitter gem来更新用户状态.但是,我还需要知道最近创建的状态的ID,以便稍后我可以删除它.这里有什么指导?