Help us understand the problem. What is going on with this article?

目的のハッシュタグを含むツイートをした人のユーザーネーム(@の後ろの部分)を取得する

More than 3 years have passed since last update.

Player!は、twitterに同時投稿した際に#playerappがつきます。
そのハッシュタグのついた投稿をしている人のscreen_name(@の後ろの部分)を取得するためのスクリプトです。

`gem install twitter'にてgemをインストール

twitter.rb
require "twitter"

# Twitter APIによるリクエスト
client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "CONSUMER_KEY"
  config.consumer_secret     = "CONSUMER_SECRET"
  config.access_token        = "ACCESS_TOKEN"
  config.access_token_secret = "ACCESS_TOKEN_SECRET"
end

# 取得するツイートの上限数
limit   = 10

# 欲しいハッシュタグのキーワード
tag = "playerapp"

# ここでスクリーンネームを取得
client.search("##{tag}", lang: 'ja', result_type: 'recent', count: 1).take(limit).map do |tweet|
  puts "#{tweet.user.screen_name}"
end

取得するツイートの上限数は、Twitter APIのリクエスト制限があるので、それに引っかからない程度に設定してください。
参考記事:FacebookとTwitterのAPIのコール回数の制限について

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away