僕の世界観を変えてみる

文系男子が趣味でプログラミングを勉強していくブログです。他にも日常で起きたどうでもいいことや愚痴を書いていきたいです。座右の銘は和を以て貴しとなすです。仲良くやろうよ。

【例文あり】TwitterAPIの登録に苦戦した、そんな話

f:id:htmllifehack:20190406204129j:plain

TwitterAPIの登録にとても苦労した話。

TwitterAPI自体は2017年の9月に登録はしていたんだけど、今年になってから使ってみたら使用できないようになっていたんですよ。

なんでもTwitterAPIの規約が変わったようで作り直さないといけなくなったとかなんとか?

今までのKeyを再生成しても使えなかったので再登録することにしました。

www.htmllifehack.xyz

TwitterAPIの確認事項

TwitterAPIを使うとTwitterを開かなくてもツイートやリツイート、いいねなどすることができます。

TwitterAPIを利用するにはDeveloper登録する必要があります。

登録の際に審査があり、審査に通らないと利用することができません。

また審査に落ちたアカウントは二度とAPIを利用できなくなるなんて話もちらほら。

とは言っても1発で退場させられるわけではありません。

まず登録の際に300文字以上でTwitterAPIを使う理由を英語で語る必要があります。

ここがなかなか鬼門です。

いくつか必要事項を入力したあとTwitterAPIを使う理由を記入し、送信します。

数日でTwitterからメールに返信があり、そこで結果が発表されます。

このとき、ちゃんとした理由がないともっと詳しく書いてくれという内容のメールがきます。

僕はこれを4~5回繰り返したので最低でもこのくらいはやり直しが効くということです。

ただし、規約が変わればそうもいかなくなるのでやるなら真剣にやりましょう。

以下成功例と失敗例を載せておきます。

(失敗例)describe in your own words what you are building

300文字でTwitterにアピール

1.What is the core use case, intent, or purpose for your use of Twitter’s APls?

2.Do you intend to analyze Tweets, Twitter users, or their content? If so, share details about the analyses plan to conduct and the methods techniques you plan to use

3.Does your use case involve Tweeting, Retweeting, or liking content? If so, share how you will interact with Twitter users or their content.

4.How will Twitter data be displayed to users of your solution? If you plan display Twitter content off of Twitter, explain how and where Tweets and Twitter content will be displayed to users of your product or service. Will individual Tweets and Twitter or will information about Tweets or Twitter content be displayed in aggregate?

これなんですけど、Google翻訳してみると

翻訳後

1.TwitterのAPlsを使用する際の中心的なユースケース、意図、または目的は何ですか?

2.ツイート、Twitterユーザー、またはそれらのコンテンツを分析しますか。 もしそうなら、実行する分析計画とあなたが使用することを計画する方法テクニックについての詳細を共有しなさい。

3.あなたのユースケースには、ツイート、リツイート、またはいいねが含まれますか。 もしそうなら、Twitterのユーザーやそのコンテンツとどのようにやり取りするのかを共有しましょう。

4.Twitterのデータは、ソリューションのユーザーにどのように表示されますか? Twitter以外のTwitterコンテンツを表示する予定の場合は、ツイートやTwitterコンテンツを表示する方法と場所を製品またはサービスのユーザーに説明します。 個々のツイートとTwitter、またはツイートやTwitterのコンテンツに関する情報はまとめて表示されますか。

これに対して僕はこう答えました。

  1. Botなどプログラミングの勉強のためです。
  2. ツイートを形態素解析してBotを作成します。また、現在のトレンドから大衆がどのようなものに興味があるのかマーケティングにも利用する予定です。
  3. 自動でツイートするBotを考案しています。
  4. 形態素解析したデータをもとに作成した文章をツイートとして、あるいはwebページを用意して公開することも考えています。

300文字を超えるようにひねり出した回答です。

しかしこれでは通りませんでした。

ちなみに、やり直しのときはこのようなメールが届きます。

やり直し

Thank you for your response.


At this time, we still do not have enough specific information about your intended use case to complete review of your application. As a reminder, we previously requested additional information about:


- The core use case, intent, or business purpose for your use of the Twitter APIs
- Note that “business purpose” in this context includes uses not necessarily connected to a commercial business. We require information about the problem, user story, or overall goal your use of Twitter content is intended to address.

- If you are a student, learning to code, or just getting started with the Twitter APIs, please provide details about potential projects or areas of focus.


- If you intend to analyze Tweets, Twitter users, or their content, share details about the analyses you plan to conduct and the methods or techniques

- Note that “analyze” in this context includes any form of processing performed on Twitter content. Please provide as detailed and exhaustive an explanation as possible of your intended use case.


- If your use involves Tweeting, Retweeting, or liking content, share how you will interact with Twitter users or their content.


- If you’ll display Twitter content off of Twitter, explain how and where Tweets and Twitter content will be displayed to users of your product or service, including whether Tweets and Twitter content will be displayed at row level or aggregated

- Where possible, please share links to illustrations and/or sample work products. Note that we can’t view attachments.


To provide this information to Twitter, reply to this email. Failure to provide the necessary information will result in the rejection of your application.


Thank you for your interest in building on Twitter.

ハイフンが付いているところが必要事項です。

そしてもっと詳しく、例えば形態素解析にはpythonとjanomeやmecabを使いますだとか、参考例だとか自分がやってるブログのリンクを貼ってみたりだとかしてみたわけです。

これを3回くらい繰り返してまた同じメールが返ってきたのでやけになってイギリス人の友達に連絡してみたところ

「APIがなんなのかわからんけあれやけどたぶんこう言っとるんと違う?」っていうアドバイスをもらいましたがちょっと何を言ってるのか僕にはわからなかったのでThank youとだけ返信しときました。

もうだめだお手上げだわと思ってたそのとき私、気づいちゃったんです。

規約を遵守するむねを書いていないことを。

(成功例)describe in your own words what you are building

・If you are a student, learning to code, or just getting started with the Twitter APIs, please provide details about potential projects or areas of focus.
>> I want to learn to programming and get starting with the Twitter APIs using python and GAS.

・If you intend to analyze Tweets, Twitter users, or their content, share details about the analyses you plan to conduct and the methods or techniques
>> We use mecab for morphological analysis.(https://github.com/ellie-icekler/MeCab-python)
>> Use chasen to retrieve words from tweets.
>> Put the extracted word data in wordcloud and create an image.(Put the extracted word data in wordcloud and create an image.)

・If your use involves Tweeting, Retweeting, or liking content, share how you will interact with Twitter users or their content.
>> I don't think about tweet and retweet and liking content.

・Where possible, please share links to illustrations and/or sample work products. Note that we can’t view attachments.
>> python library for the Twitter API Tweepy (https://github.com/tweepy/tweepy)
>> GAS library for the Twitter API TwitterWebSerice.gas (https://gist.github.com/M-Igashi/750ab08718687d11bff6322b8d6f5d90)
>> Sample of the service you want to create (https://apps.twiexam.com/crime)
>> It is not what I made.


Twitterは前々からスパム行為を禁止する意向を示していました。

スパム行為とは例えば、いいねを水増しする、短時間でフォローを繰り返す、ダイレクトメッセージを繰り返し送る、同ツイートを繰り返し連続でツイートするなどが当たります。

Twitterはこれらを禁じより質のよい、より使いやすい環境を作ることを優先しています。

つまりTwitterAPIを用いてスパムに当たる行為を行わないと宣誓する必要があったわけです。

ということでツイートとリツイートといいねは自動でしませんよって書いておきました(笑)

加えて使用する予定のライブラリのURLと具体例として参考にするURLと言語の指定をしておきました。

※実際Botを作ったので自動でのツイートはしています。が、規約を守り最短で1時間に1ツイートにとどめています。

blog.twitter.com

まとめ

どうでしょうか。

TwitterAPIの規約が厳しくなったとされていて、数年前は簡単にAPI登録もできたのに最近では審査に通らないとAPIが使えなくなりました。

それに伴いなかなか通らない人もいるようで参考になればなと思い書いてみました。

中には300文字の部分は適当に書いたけど登録できた、なんて方もいらっしゃるみたいで、上手に説明できたんでしょうか?

逆に3回やってやっと通ったって方もいらっしゃいます。

大丈夫、僕なんて5回ほどやり直ししてるんです。

恥ずかしいことなんてないですよ!