Module: GetFollow
- Included in:
- TweetTop::User
- Defined in:
- lib/get_follow.rb
Instance Method Summary collapse
- #get_followers(user_id, results: 100, info: "description,name,username,url", format: "json") ⇒ Object
- #get_following(user_id, results: 100, info: "description,name,username,url", format: "json") ⇒ Object
Instance Method Details
#get_followers(user_id, results: 100, info: "description,name,username,url", format: "json") ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/get_follow.rb', line 5 def get_followers(user_id, results: 100, info: "description,name,username,url", format: "json") '''info parameter options (must be a string with the required options): created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld default info: description,name,username,url''' url = "https://api.twitter.com/2/users/#{user_id}/followers" info = info.gsub(" ", "") params = { "max_results" => results, "user.fields" => info } = { method: 'get', headers: { "Authorization": "Bearer #{@bearer_token}" }, params: params } request = Typhoeus::Request.new(url, ) response = request.run if format == "ruby" return JSON.parse(response.body.to_s) elsif format == "code" return response.code else return JSON.pretty_generate(JSON.parse(response.body)) end end |
#get_following(user_id, results: 100, info: "description,name,username,url", format: "json") ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/get_follow.rb', line 38 def get_following(user_id, results: 100, info: "description,name,username,url", format: "json") '''info parameter options (must be a string with the required options): created_at, description, entities, id, location, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, withheld default info: description,name,username,url''' url = "https://api.twitter.com/2/users/#{user_id}/following" info = info.gsub(" ", "") params = { "max_results" => results, "user.fields" => info } = { method: 'get', headers: { "Authorization": "Bearer #{@bearer_token}" }, params: params } request = Typhoeus::Request.new(url, ) response = request.run if format == "ruby" return JSON.parse(response.body.to_s) elsif format == "code" return response.code else return JSON.pretty_generate(JSON.parse(response.body)) end end |