/ / ट्विटर रत्न के साथ रेल उपयोगकर्ता फ़ीड को कैसे प्रदर्शित करें - रूबी-ऑन-रेल, रूबी, ट्विटर, ट्विटर-ओउथ, ट्विटर-रत्न

ट्विटर मणि के साथ रेल में ट्विटर उपयोगकर्ता फ़ीड कैसे प्रदर्शित करें - रूबी-ऑन-रेल, रूबी, ट्विटर, ट्विटर-ओथ, ट्विटर-मणि

Im अपने ट्विटर फीड से 3 स्टेटस दिखाने और दिखाने के लिए रेल रत्न का उपयोग कर रहा हूँ। मैं प्रलेखन के अनुसार सब कुछ कर रहा हूँ, लेकिन यह मेरे विचार में कुछ भी प्रदर्शित नहीं कर रहा है।

मेरे एप्लिकेशन कंट्रोलर में मुझे "यह नीचे मिल गया:"

client = Twitter::REST::Client.new do |config|
config.consumer_key        = "***********"
config.consumer_secret     = "***********"
config.access_token        = "***********"
config.access_token_secret = "***********"

end



def client.get_all_tweets(user)
options = {:count => 3, :include_rts => true}
user_timeline(user, options)
end


@tweet_news = client.get_all_tweets("tezzataz")

तब मेरे विचार में मैंने बस:

<% @tweet_news %>

मुझे कोई त्रुटि नहीं हुई, लेकिन मेरे विचार में कुछ भी नहीं दिखा। किसी भी मदद की बहुत सराहना की जाएगी!

उत्तर:

जवाब के लिए 0 № 1

इसी उद्देश्य के लिए इसका इस्तेमाल किया।

<ul>
<% @tweet_news.each do |f| %>
<li>
<%= f.text%>
<span><%= time_ago_in_words(f.created_at) %> ago</span>
</li>
<% end %>
</ul>

जवाब के लिए 0 № 2

नियंत्रक

require "twitter"

class TweetController < ApplicationController
def index
client = TweetController.create_client
begin
@tweets = get_tweets(client)
rescue => e
#TODO: render 404 with the error
puts "Error : #{e.to_s}"
end
end

private
def get_tweets(client, userName)
client.user_timeline(userName, :count => 200)
end
end

राय

<div class="row">
<div class="col-lg-12">
<ul class="timeline">
<% @tweets.each do |tweet| %>
<div class="timeline-image">
<!-- Show user avatar (profile pic)-->
<img class="img-circle" src= "<%= image_path(tweet.user.profile_image_url_https.to_s.gsub("_normal","")) %>" alt="" style="width: 100%;height: 100%;">
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<!-- Show user name -->
<h4> <%= tweet.user.name %></h4>
<h4 class="subheading"> <%= "@#{tweet.user.screen_name}"  %> </h4>
</div>
<div class="timeline-body">
<p class="text-muted"> <%= tweet.text%> </p>
<i class="fa fa-retweet"> <%= tweet.retweet_count %> </i>
<i class="fa fa-heart"> <%= tweet.favorite_count %> </i>
</div>
</div>
</li>
<% end %>
</ul>
</div>
</div>