<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>【python Twitter API】タグの記事一覧｜python-manブログ</title>
	<atom:link href="https://python-man.club/tag/python-twitter-api/feed/" rel="self" type="application/rss+xml" />
	<link>https://python-man.club</link>
	<description>独学者でもpythonでアプリを作れる！</description>
	<lastBuildDate>Sun, 17 Jul 2022 13:29:13 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.2</generator>
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>pythonでtwitter APIを取得する方法【全18枚の図解+例文あり】</title>
		<link>https://python-man.club/python_twitter_api/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=python_twitter_api</link>
					<comments>https://python-man.club/python_twitter_api/#comments</comments>
		
		<dc:creator><![CDATA[syou0445]]></dc:creator>
		<pubDate>Sat, 19 Feb 2022 14:52:11 +0000</pubDate>
				<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[python Twitter API]]></category>
		<guid isPermaLink="false">https://python-man.club/?p=646</guid>

					<description><![CDATA[pythonの学習を進めていくと、「twitterもpythonで操作できるかも#8230;？」 「twitterのbot作ってみたい#8230;」と思う方もいるかと思います pythonでは「tweepy」というラ]]></description>
										<content:encoded><![CDATA[<p>pythonの学習を進めていくと、「<strong>twitterもpythonで操作できるかも&#8230;？</strong>」</p>
<p>「<strong>twitterのbot作ってみたい&#8230;</strong>」と思う方もいるかと思います</p>
<p>pythonでは「tweepy」というライブラリを使用すれば、簡単にbotを作ることができます</p>
<p>今回の記事では、</p>
<div class="simple-box2">
<p style="text-align: center;"><strong><span class="marker2">pythonでtwitterを操作してみたい</span></strong></p>
<p style="text-align: center;"><strong><span class="marker2">pythonでtwitterのbotを作成したい</span></strong></p>
<p style="text-align: center;"><strong>といった方に向けて、<span class="marker">twitter APIの取得方法について</span>書いていきます！</strong></p>
<p style="text-align: center;"><strong>短時間でpythonを学びたい方は、こちらがおすすめ</strong></p>
<p>https://python-man.club/python_how_to_study_beginner/</p>
</div>
<p><span style="color: #ff0000;"><strong>pythonでtwitterを扱えるようになると、twitterで行われている懸賞に自動で応募することができるようになります</strong></span></p>
<p><a href="https://note.com/python_poikatsu/n/nd73221697653">pythonを使ったtwitter自動化-twitter懸賞自動応募で当選実績あり-</a></p>
<div class="concept-box5">
<p style="text-align: center;"><span style="font-size: 28px;"><strong>おすすめ書籍</strong></span></p>
<div class="booklink-box" style="text-align: left; padding-bottom: 20px; font-size: small; zoom: 1; overflow: hidden;">
<div class="booklink-image" style="float: left; margin: 0 15px 10px 0;"><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_202202192350098157?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F16437744%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener"><img decoding="async" style="border: none;" src="https://thumbnail.image.rakuten.co.jp/@0_mall/book/cabinet/9274/9784873119274.jpg?_ex=200x200" /></a></div>
<div class="booklink-info" style="line-height: 120%; zoom: 1; overflow: hidden;">
<div class="booklink-name" style="margin-bottom: 10px; line-height: 120%;">
<p><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_202202192350098157?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F16437744%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener">退屈なことはPythonにやらせよう　第2版</a></p>
<div class="booklink-powered-date" style="font-size: 8pt; margin-top: 5px; font-family: verdana; line-height: 120%;">posted with <a href="https://yomereba.com" target="_blank" rel="nofollow noopener">ヨメレバ</a></div>
</div>
<div class="booklink-detail" style="margin-bottom: 5px;">AI Sweigart/相川愛三 オライリー・ジャパン 2022年07月27日頃</div>
<div class="booklink-link2" style="margin-top: 10px;">
<div class="shoplinkrakuten" style="display: inline; margin-right: 5px;"><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_202202192350098157?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F16437744%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener">楽天ブックス</a></div>
<div class="shoplinkamazon" style="display: inline; margin-right: 5px;"><a href="https://www.amazon.co.jp/exec/obidos/asin/4873119278/baseball0445-22/" target="_blank" rel="noopener">Amazon</a></div>
<div class="shoplinkkindle" style="display: inline; margin-right: 5px;"><a href="https://www.amazon.co.jp/gp/search?keywords=%E9%80%80%E5%B1%88%E3%81%AA%E3%81%93%E3%81%A8%E3%81%AFPython%E3%81%AB%E3%82%84%E3%82%89%E3%81%9B%E3%82%88%E3%81%86%E3%80%80%E7%AC%AC2%E7%89%88&amp;__mk_ja_JP=%83J%83%5E%83J%83i&amp;url=node%3D2275256051&amp;tag=baseball0445-22" target="_blank" rel="noopener">Kindle</a></div>
</div>
</div>
<div class="booklink-footer" style="clear: left;"></div>
</div>
<div class="booklink-box" style="text-align: left; padding-bottom: 20px; font-size: small; zoom: 1; overflow: hidden;">
<div class="booklink-image" style="float: left; margin: 0 15px 10px 0;"><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_20220219235101556?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F12824917%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener"><img decoding="async" style="border: none;" src="https://thumbnail.image.rakuten.co.jp/@0_mall/book/cabinet/6792/9784873116792.jpg?_ex=200x200" /></a></div>
<div class="booklink-info" style="line-height: 120%; zoom: 1; overflow: hidden;">
<div class="booklink-name" style="margin-bottom: 10px; line-height: 120%;">
<p><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_20220219235101556?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F12824917%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener">入門　ソーシャルデータ</a></p>
<div class="booklink-powered-date" style="font-size: 8pt; margin-top: 5px; font-family: verdana; line-height: 120%;">posted with <a href="https://yomereba.com" target="_blank" rel="nofollow noopener">ヨメレバ</a></div>
</div>
<div class="booklink-detail" style="margin-bottom: 5px;">Matthew A. Russell/佐藤敏紀 オライリー・ジャパン 2014年06月</div>
<div class="booklink-link2" style="margin-top: 10px;">
<div class="shoplinkrakuten" style="display: inline; margin-right: 5px;"><a href="https://hb.afl.rakuten.co.jp/hgc/18cb6363.e8f8b707.18cb6364.c87e7f42/yomereba_main_20220219235101556?pc=http%3A%2F%2Fbooks.rakuten.co.jp%2Frb%2F12824917%2F%3Fscid%3Daf_ich_link_urltxt%26m%3Dhttp%3A%2F%2Fm.rakuten.co.jp%2Fev%2Fbook%2F" target="_blank" rel="noopener">楽天ブックス</a></div>
<div class="shoplinkamazon" style="display: inline; margin-right: 5px;"><a href="https://www.amazon.co.jp/exec/obidos/asin/4873116791/baseball0445-22/" target="_blank" rel="noopener">Amazon</a></div>
<div class="shoplinkkindle" style="display: inline; margin-right: 5px;"><a href="https://www.amazon.co.jp/gp/search?keywords=%E5%85%A5%E9%96%80%E3%80%80%E3%82%BD%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%83%87%E3%83%BC%E3%82%BF&amp;__mk_ja_JP=%83J%83%5E%83J%83i&amp;url=node%3D2275256051&amp;tag=baseball0445-22" target="_blank" rel="noopener">Kindle</a></div>
</div>
</div>
<div class="booklink-footer" style="clear: left;"></div>
</div>
</div>
<p><a href="https://python-man.club/python_twitter_api_tweet/">twitter API取得後に、pythonからツイートする方法</a></p>
<p><a href="https://python-man.club/python_twitter_api_fav/">twitter APIを利用してpythonからツイートにいいねする方法</a></p>
<h2>pythonでtwitterを操作するためにAPIを取得する</h2>
<p>pythonでtwitterを操作するためには、「twitter API」の取得が必要になります</p>
<p>twitter APIを取得するために、<a href="https://developer.twitter.com/en/apps/">デブロッパーサイト</a>に飛びます</p>
<h3>1.create an app</h3>
<p>デブロッパーサイトに飛んだら、「<strong>Create an app</strong>」をクリックします</p>
<img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-647" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_921b11b1eb7a2ecf7d0ff85b214f149a.png.webp" alt="create an app" width="800" height="421" />
<h3>2.デブロッパーサイトの承認</h3>
<p>その後、承認画面が出てくるので、「<strong>Apply</strong>」をクリックします</p>
<img decoding="async" class="alignnone size-full wp-image-648" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_f1b379085dbf85f2535761a7ea9f9caf.png.webp" alt="デブロッパーサイト承認" width="800" height="392" />
<h3>3.必要項目の入力</h3>
<p>次に、以下の4項目をそれぞれ入力していきます</p>
<p>3項目目は好きなものを選びましょう</p>
<p>私は「<strong>Making a bot</strong>」にしています</p>
<p>4項目目は「<strong>No</strong>」にしておき、最後のチェックボックスは空欄にしておきましょう</p>
<p>チェックを入れるとメルマガが来るようになります</p>
<img decoding="async" class="alignnone size-full wp-image-649" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_63bac0709df6f49b157789ae280dc852.png.webp" alt="making a bot" width="800" height="383" />
<h3>4.submit</h3>
<p>「<strong>Next</strong>」をクリック後、「<strong>submit</strong>」もクリックしましょう</p>
<img decoding="async" class="alignnone size-full wp-image-650" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_d7bdf42494fb255ea025fc4e400db334.png.webp" alt="submit" width="800" height="360" />
<p>この時、ログインしているtwitterアカウントに電話番号を登録していないと、submitすることができないので、submitする前に登録しておきましょう</p>
<h3>5.twitter API承認画面</h3>
<p>submit後、以下の画面になります</p>
<img decoding="async" class="alignnone size-full wp-image-651" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_3919283875c448138f8b779e7a80c97d.png.webp" alt="submit後画面" width="800" height="371" />
<h3>６.メール確認画面</h3>
<p>twitterアカウントに登録しているメールアドレスに、メールが届くので、そちらを確認します</p>
<img decoding="async" class="alignnone size-full wp-image-652" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_d02f9530355e691026dde97fc12e878f.png.webp" alt="認証メール" width="800" height="406" />
<h3>7.Confirm your email</h3>
<p>メールを確認したら、「<strong>Confirm your email</strong>」をクリックします</p>
<p>クリック後、デブロッパーサイトに飛びます</p>
<img decoding="async" class="alignnone size-full wp-image-653" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_84b9eec1fab31fe85c92ad6f06703517.png.webp" alt="認証後デブロッパーサイト" width="800" height="383" />
<p>この画面にtwitter APIキーなどが表示されています</p>
<p>コピペして、どこかに保存しておきましょう</p>
<p>仮に保存し忘れても、後から確認することは可能です</p>
<h3>8.ダッシュボードの確認</h3>
<p>保存後、「<strong>skip to dashborad</strong>」をクリックします</p>
<img decoding="async" class="alignnone size-full wp-image-654" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_d90624df58157c7c761e8d77dcef1578.png.webp" alt="twitter APIダッシュボード" width="800" height="378" />
<p>これでtwitter APIの取得は完了です</p>
<p>次からはtwitter APIを取得した後の流れになります</p>
<h2>twitter API取得後に、アプリを登録する</h2>
<p>まずはダッシュボードのページに飛びます</p>
<h3>1.Projects &amp;Apps</h3>
<p>その後、ダッシュボードの左側「<strong>Projects &amp;Apps</strong>」をクリックします</p>
<img decoding="async" class="alignnone size-full wp-image-655" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_5c20ecc476cda46aa01bd34bdb3bef81.jpeg.webp" alt="ダッシュボード" width="720" height="405" />
<p>その後、「<strong>Project1</strong>」の下にある「<strong>〜〜〜〜〜</strong>」をクリックします</p>
<img decoding="async" class="alignnone size-full wp-image-656" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_665316527475a173e0b15fbc82f69469.jpeg.webp" alt="Twitter API project1" width="720" height="405" />
<h3>2.set up</h3>
<p>続いて、「<strong>set up</strong>」をクリック</p>
<img decoding="async" class="alignnone size-full wp-image-657" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_95f4f6d7314e0c9a9c4c7c8c16d56ff8.jpeg.webp" alt="Twitter API setup" width="720" height="405" />
<p>「<strong>OAuth 1.0a</strong>」を選択します</p>
<img decoding="async" class="alignnone size-full wp-image-658" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_dc42b3e2f162a10f95b456132edb02e0.jpeg.webp" alt="OAuth1.0α" width="720" height="405" />
<p>「<strong>Read and write</strong>」を選択し、「<strong>Callback URL</strong>」「<strong>Website URL</strong>」に以下のサイトのURLを入力します</p>
<p><a href="https://tools.tsukumijima.net/twittertoken-viewer/">twitter APIのアクセストークンを確認するやつ</a></p>
<img decoding="async" class="alignnone size-full wp-image-659" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_5f60aaa4283d1ea987db7922b339b301.jpeg.webp" alt="twitter アクセストークンを確認する" width="720" height="405" />
<p>「<strong>save</strong>」をクリック</p>
<img decoding="async" class="alignnone size-full wp-image-660" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_d32d9857530289790544c0adb35fefb9.jpeg.webp" alt="twitterAPI save" width="720" height="405" />
<h3>3.サードパーティアプリの承認</h3>
<p>先ほどの<a href="https://tools.tsukumijima.net/twittertoken-viewer/">twitter APIのアクセストークンを確認するやつ</a>に飛んで、コピペして保存しておいた「<strong>コンシューマーキー(API Key)</strong>」と「<strong>コンシューマーシークレットキー(API secret key)</strong>」を入力します</p>
<img decoding="async" class="alignnone size-full wp-image-661" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_f168016b740d48bbafbf331e62f33e33.jpeg.webp" alt="twitter api登録" width="720" height="405" />
<p>そうするとtwitter側でサードパーティアプリの使用認証画面に飛ぶので、認証します</p>
<img decoding="async" class="alignnone size-full wp-image-662" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_c90e294895c0c1fd8ff69d08894b45b2.jpeg.webp" alt="twitter APIサードパーティアプリ" width="720" height="405" />
<p>これでpythonで作成したアプリを使用して、twitterを操作できるようになります</p>
<h2>twitter APIをApply for Elevatedする</h2>
<p>ここまでで取<strong><span class="marker">得したtwitter APIではツイートは可能ですが、いいねやリツイート、フォローなどを行うことができません</span></strong></p>
<p>そのため、いいねやリツイートなどが行えるように<strong><span class="marker">twitter APIをApply for Elevated</span></strong>していきます</p>
<p>英語で質問されますので、英語で返していきましょう</p>
<h3>1.In your words</h3>
<p><strong>「We use the Twitter API to create a bot program that posts automatically. Use the API to automatically post tweets about recommended products that are listed in the popularity ranking using Google Apps Script.」</strong></p>
<h3>2.Are you planning to analyze Twitter data?</h3>
<p><strong>ここはtwitter APIで取得した内容を解析などに使うかどうかです</strong></p>
<p>botの作成であれば使用しないため、「<strong>No</strong>」にしておきましょう</p>
<h3>3.Will your app use Tweet, Retweet, Like, Follow, or Direct Message functionality?</h3>
<p><strong><span class="marker">作成したpythonのアプリでツイート・RT・fav・フォロー・DMを使用するかどうかです</span></strong></p>
<p>ここは使用するため「<strong>Yes</strong>」にして、以下のように書いておきます</p>
<p><strong>「We plan to create a Bot function that automatically tweets the articles created on the blog.</strong><br />
<strong>We will also create a function to automatically follow people who like or retweet the bot&#8217;s tweets.</strong><br />
<strong>I also want to create a feature that automatically sends a thank you direct message to users who follow my account.」</strong></p>
<h3>4.Do you plan to display Tweets or aggregate data about Twitter content outside Twitter?</h3>
<p><strong>Twitterのコンテンツに関するツイートや集計データをTwitterの外部で表示する予定はありますか？</strong></p>
<p>ということです</p>
<p>ここはBotでは使用しないので「<strong>No</strong>」にします</p>
<h3>5.Will your product, service, or analysis make Twitter content or derived information available to a government entity?</h3>
<p><strong>貴社の製品、サービス、分析によって、Twitterのコンテンツや派生する情報を政府機関が利用できるようになりますか？</strong></p>
<p>ただのBotなので「<strong>No</strong>」にします</p>
<p><strong><span class="marker">あとは「Next」をクリックして、「Submit」すれば完了です</span></strong></p>
<p>その後、pendingされるので、認証のメールを待ちましょう</p>
<p>以下のような承認メールが来たらダッシュボードに変化がありますので、確認してみましょう</p>
<img decoding="async" class="alignnone size-full wp-image-663" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_fdc7af958f7d8502b8fe1fb43fc7e654.png.webp" alt="twitter api追加承認" width="800" height="333" />
<img decoding="async" class="alignnone size-full wp-image-664" src="https://python-man.club/wp-content/uploads/2022/02/picture_pc_f8c681031ee1c313e7bce1acc8a86fc0.jpeg.webp" alt="承認後ダッシュボード" width="720" height="405" />
<p><strong><span class="marker">pythonでtwitter API利用する方法はこれでおしまいです</span></strong></p>
<p>作成したアプリを自動化する方法やtwitterをうまく活用するためのコードは以下のnoteをご確認ください</p>
<p><a href="https://note.com/python_poikatsu/n/nd73221697653">pythonを使ってtwitterの自動化</a></p>
<p>次回は<a href="https://python-man.club/python_twitter_api_tweet/"><strong>pythonでtwitter APIを利用してツイートを取得する</strong></a>方法について解説していきます！</p>
<div class="concept-box5">
<p style="text-align: center;"><span style="font-size: 20px;"><strong>おすすめプログラミングスクール(無料体験あり)<br />
</strong></span></p>
<p>https://python-man.club/python_recommendation_school/
</p></div>
]]></content:encoded>
					
					<wfw:commentRss>https://python-man.club/python_twitter_api/feed/</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
			</item>
	</channel>
</rss>
