A story about a student who was spared due to the SARS-CoV-2 epidemic and finally made a Twitter App and finally hit the limit of the Twitter API

Introduction

When you run into a problem, you guys google, right? This time, I googled when I was restricted by the API, but there is not much information in Japanese that comes out. .. ..

Therefore, I decided to write this article in the hope that it would help someone who has fallen into the same situation as me. (** It will be a shame, but **) (In spite of **, there are quite a few things that I want to write ) ( In other words, there are so many stories **)

This story is a record for everyone to carry out "** Attack the ball with stones from other mountains **". I pray that you will not follow the same rut as I do. .. ..

(** If you only need to know how to remove the restrictions on the Twitter API **, it is enough to read only Summary)

March 2020

A new type of coronavirus called SARS-CoV-2 has become prevalent. I hope the person reading this says "That happened" ... Due to the influence of this virus, schools all over the country have taken measures to close.

As a result, I, a second year high school student (third year high school student in 2020), could not go to school either. My school is a self-proclaimed school, but I didn't give any assignments and took the stance of "do your best by self-study".

April 2020

On February 27th (Is it right?), Prime Minister Abe requested that schools nationwide be closed, and the period was extended even after April. As expected, my school also mailed the assignments, and it became a form of "home study".

April 14, 2020 midnight to April 15, early dawn

Immediately before entering this school holiday, some words were said to make my mouth sour and my ears hurt.

"** If you are a student of this school, check Classi and the school's website every day !! **"

(Digression: The combo of access concentration in this uproar and Unauthorized access has damaged the student's reputation for Classi)

Of course, I am also a student of "this school", so I read these two things every day without fail. But,

**…Yup. It's annoying. ** **

Then, at dawn on the 15th (around 1:00), ** Let's create a service that monitors the school's website and notifies you when it is updated! I decided to **.

April 15, 2020 morning

I immediately started to put this idea into shape.

"Is it Java after all?" (← ** Almost only Java can be used **) "Use Gradle" (← ** Gradle I don't understand but it's convenient **) "If it is updated so that everyone can see it, it will be posted on Twitter" (← ** Important here **)

While thinking about various things, I finished making it quickly in about an hour (according to my vague memory). The specifications are like this ↓

・ Assuming constant operation on Raspberry Pi
・ Access the school website every few minutes
・ Compare with the data acquired last time, tweet if there is a change

I used Twitter4J-4.0.7 to hit the Twitter API.

After that, we conducted a test run using the news section of Yahoo! JAPAN, detected updates normally, and confirmed that we could tweet.

April 15, 2020 around 10:00

I haven't moved to Raspberry Pi yet, and started trial operation targeting school HP with a MacBook for development. The school's HP is updated infrequently compared to Yahoo! JAPAN (let alone the news section), so I left it in this state for a while.

At this point, I locked my bot's account and could only see myself and my close friend A.

April 15, 2020 15:16

I posted a tweet saying "Librahack I'm a little worried about it ()". After all, there was no problem.

April 15, 2020 17:34

** School HP has been updated! !! !! ** ** Yes, I finally got the operation check! !! You can also tweet normally! !! I made a guts pose to my heart's content.

April 15, 2020 19:00

(** I forgot what I did **) It seems that I did some maintenance in the past. In addition, I added a playful function to say hello in the morning and at night ~~ useless ~~.

I and my friend A both turned on the bot dirt notification so that I could immediately notice the bot's tweet, but I forgot to turn it off even though my friend A turned off the notification for maintenance. It was with a bonus () Thanks to that, a lot of notifications of test tweets during maintenance ...

April 15, 2020 21:40

After the maintenance, I unlocked the bot dirt and released it to the whole world. When I advertised with my friend A, many people immediately followed me. Some people said they were "competent." (I was so happy)

Unknown date and time

I've forgotten the exact date and time, but I've probably added the ability to DM the details of the error to my Twitter account if an error occurs on the bot ** around here **. (Policy It's a story that you can read it properly. I want to tell myself in the past.)

April 16, 2020 around 16:30

Maintenance has been added to the school website, and I am temporarily unable to connect. I didn't know what I was doing ...

The bot threw ʻUnknownHostException` and learned the error when the DM came. Until this time, I was thinking, "This function is awesome!" (** I want to hit **)

Since HP had informed me in advance that maintenance would be done, I decided to leave it as "Wait a while and I'll fix it."

April 16, 2020 around 16:45

I was a little worried because I kept throwing errors intermittently, so I stopped the bot.

April 16, 2020 16:52

I restarted the bot and confirmed that it could connect to HP normally. I wonder why it didn't connect ...

April 16, 2020 17:06

The fateful time has finally arrived. I was worried if it was working properly, so I noticed it when I restarted the bot at 16:52 and looked at the log frequently.

**that? I'm getting a Twitter4J error ...? ** **

403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following).
message - Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform
code - 261

Relevant discussions can be found on the Internet at:
	http://www.google.co.jp/search?q=796590e6 or
	http://www.google.co.jp/search?q=802fbd73
TwitterException{exceptionCode=[796590e6-802fbd73], statusCode=403, message=Application cannot perform write actions. Contact Twitter Platform Operations through https://support.twitter.com/forms/platform, code=261, retryAfter=-1, rateLimitStatus=null, version=4.0.7}
	at twitter4j.HttpClientImpl.handleRequest(HttpClientImpl.java:170)
	at twitter4j.HttpClientBase.request(HttpClientBase.java:57)
	at twitter4j.HttpClientBase.post(HttpClientBase.java:86)
	at twitter4j.TwitterImpl.post(TwitterImpl.java:2138)
	at twitter4j.TwitterImpl.sendDirectMessage(TwitterImpl.java:577)
	at twitter4j.TwitterImpl.sendDirectMessage(TwitterImpl.java:611)
	at twitter4j.TwitterImpl.sendDirectMessage(TwitterImpl.java:616)

Apparently it's sick at the stage of tweeting.

For the time being, I stopped the bot and was very impatient, thinking "** But I was able to tweet normally ...? **" for the time being [Twitter Developers Apps page](https://developer.twitter.com/en / apps) was accessed.

200419-0001.png

** RESTRICTED TO API READ ACCESS ONLY ** ... (Translation: ** Your app has write restrictions. It can be read. **)

You're even more impatient. Of course googled.

screencapture-google-search-2020-04-20-13_17_35.png

There are only three pages that look like that in Japanese. I'm even more impatient.

For the time being, access How to unfreeze Twitter application | Net Bugyo displayed at the top.

Apparently, you can contact us from Twitter API Policy Support.

screencapture-help-twitter-forms-platform-2020-04-20-13_24_41.png

In the "Details" section, I filled in the following (** This is an image with a vague memory **) and also filled in other necessary items and sent it.

This app is a bot that monitors a specific website and tweets when it is updated. When an error occurred, I implemented a function to send the content of the error by DM to another account I own, but since a large number of errors occurred, it was judged that a large amount of DM was being sent and the function was released. I think it was restricted. In the future, we will take measures to increase the interval for sending DMs so that this will not happen, so please remove the restriction.

Yes. I had a terrible idea of the cause of the restriction, so I sent a message that I regretted.

Go straight to the mail folder.

** ... Isn't there anything coming? ** **

I didn't even receive the auto-reply email. Going back to the previous Net Bugyo-san's page ...

  • You may be unfrozen a few hours after you apply, unfrozen a few days later, or you may be asked additional questions.

In my case, it was accidentally frozen about 3 times, but it was canceled 5 hours after I applied.

** Hmm. Well, the people on Twitter also work from home. I was convinced that ** and decided to wait leisurely.

April 16, 2020 around 20:00

** You can't tweet, but run it locally for yourself! I thought ** and tried to start it,

** Bot "Unknown HostException" **

I just hit the limit, but now I can't connect to the school website. This is exactly ** a bee on a crying face **.

Try accessing it with Chrome on your MacBook. ... you can see it. Connect to the Raspberry Pi with ssh and ping the school HP. … ʻUnknown host. Ping on your MacBook. … ʻUnknown host.

What's in my head here? ?? ?? have become. Why can't I see it in Chrome and ping it?

**… Maybe the browser cache? ** **

Flash, delete all cache of Chrome → access in secret mode.

200420-0002.png

DNS_PROBE_FINISHED_NXDOMAIN…?? Apparently something happened when resolving the name with DNS.

~ Time for trial and error after researching various things ~

…solved. Apparently something happened around the DNS due to the maintenance that entered the school HP around 16:30 on April 16th, and the DNS cache of the router (of which 192.168.11.1) was out of date. After using Google Public DNS (8.8.8.8), I can connect normally.

(** Excuse me for being messed up from the main subject **)

April 17, 2020 around 0:20

I'm using a MacBook with an ssh client, but I can't connect between the MacBook-Raspberry Pi.

Here is my tweet at this time.

to make matters worse, swastika no longer connected to mackerel

It's strange because of the late-night tension and two bees on the crying face, but don't worry.

Since the network area is sparse, I went to ** outrage ** to turn off the power of Raspberry Pi and reinstall Raspbian. (The nice thing about the Raspberry Pi is that you can do this easily.)

April 17, 2020 around 17:00

Also, since the MacBook --Raspberry Pi died, I went to ** outrage ** again.

By the way, after clearing up the problems around DNS on April 16th Move the bot locally → Post manually to Twitter if an update is detected by looking at the log I continued to operate with that feeling.

It's been a day since I applied to lift the restrictions, but I haven't received a single email, let alone lift the restrictions. ** **

April 19, 2020 0:13

Two days after the application, there was no sound, and I was numb and decided to contact again from Twitter API Policy Support.

** However, in English. ** **

Do you remember that when you registered with Twitter Developer, it was written in English? Recalling that, ** Maybe the developers are limited to English? .. I was worried about **, so I made use of the ability of ~~ ** Eiken 2nd grade, CEFR B1 ** ~~ (It's a lie DeepL I entered the details field in English and sent it.

I sent the same message in Japanese a few days ago, but I would like to send it in English as well, just in case. I apologize for the duplication. This app is a bot that monitors a specific website and tweets when it detects an update. I had implemented a function to send a DM to another account I own (@username) when an error occurs, but due to the large number of errors , I think it was judged that this bot sent a large number of DMs and was restricted. To prevent this from happening in the future, I have removed that feature, so please remove the restriction. Thank you.

Go straight to your mail folder.

Hello,

Thanks for reaching out. Your app has been restricted or suspended due to one or more violations of our Developer Agreement and Policy,AutomationRules,DisplayRequirementsand/orTwitterRules. Common reasons for this happening include:

・ Users reporting content posted through your app as spam (Tweets, RTs, favs, DMs, etc.) ・ Abusive use of automations, like auto-following / unfollowing ・ Suspicious API usage, such as repeatedly hitting rate limits ・ Display violations regarding how you must show Tweets

This list is not exhaustive, so review our policy documentation to ensure that your app and your app’s users are following all of our rules.

Please respond to this email if you need further clarification, but note that we will only consider a request to lift this restriction after you provide us with the following information:

・ App ID and consumer key ・ Link to and instructions on how to log into your app to review it for compliance ・ A list of specific changes that you have made to resolve policy non-compliance

We will not respond to requests to lift restrictions that do not include this information.

Regards,

Twitter Platform Operations

** Automatic reply came! !! !! !! ** **

At this point, I'm already excited. ** At a level where grin does not stop. ** ** However, I don't know what Twitter is saying, so ** translation **.

Thank you for contacting me. I restricted it because your app violated some rules. It seems that it is often restricted at such times.

・ When someone reports this app as spam ・ When automation is abused, such as automatically following or unfollowing ・ When you get stuck in the API limit many times ・ When you violate the rules for showing tweets on your own web

Reasons for limitation This is not the only reason. Think hard about what you did.

If you have any questions, please reply to this email. But if we don't give this information, we won't lift the restrictions.

・ App ID and consumer key ・ How to log in to the app ・ What was changed so as not to be restricted

Please be aware that we will not reply to emails that do not include these people, such as "Please lift the restrictions."

From the person on Twitter

**… I'm glad I wrote so much in the "Details" column! !! ** **

So I will send you an email almost as it is written in the details column. (I copied and saved what I wrote just in case)

Hello. I'm Japanese, so I'm not good at English. I apologize for it.

・ App ID and consumer key App ID: < App ID > Consumer Key: < Consumer Key >

・ Link to and instructions on how to log into your app to review it for compliance This app has no website. It just tweets. My profile is:

・ A list of specific changes that you have made to resolve policy non-compliance I had implemented a function to send a DM to another account I own (@username) when an error occurs, but due to the large number of errors, I think it was judged that this bot sent a large number of DMs and was restricted . To prevent this from happening in the future, I have removed that feature.

Sincerely,

… Huh.

April 19, 2020 around 14:10

Ever since Move the bot locally → Post manually to Twitter if an update is detected by looking at the log I continued to operate it like that, but it's hard to see the logs diligently.

So I decided to run it as a Discord Bot until the write restrictions were lifted.

I used JDA-4.0.0_39 to hit the Discord API, and the implementation was completed in a few hours.

April 21, 2020 around 12:00

Up to this point, Twitter (although it is still restricted) and Discord are supported, but for some reason I want to support LINE as well. After searching for a bit, I found something called LINE Messaging API SDK for Java, so I implemented it in about an hour.

By the way, I haven't received a reply from Twitter yet.

June 4, 2020 7:50

Yes, about a month and a half after replying to the email, I finally received a reply from Twitter this morning.

Hello @ username,

Thank you for reaching out. We have reviewed your request and have reactivated your API key. Going forward, carefully ensure that your application adheres to Twitter’s policies:

Developer Agreement and Policy

Automation Rules

Twitter Rules

Please note, applications found to be violating policy again may be subject to permanent suspension.

Regards,

Twitter Platform Operations

↓ Translated.

@Username, Chiss.

Thank you for contacting me. I read what you were saying and removed the API restrictions. What I want to do by observing this rule properly.

Developer Agreement and Policy

Automation Rules

Twitter Rules

Be aware that if you violate the policy again in the future, you may be able to use this account forever.

Then.

Twitter Platform Operations

** Okay! !! ** ** This ↓ that was displayed on the Twitter Developers Apps page has also disappeared.

200419-0001.png

After that, I changed the setting so that the bot tweeted, and I was able to confirm that I could tweet firmly. Thus, the battle of I VS Twitter ended. .. ..

Summary

What to do if you are restricted by the Twitter API

-Inquire from Twitter API Policy Support. -** However, the details column should be in English as much as possible **

screencapture-help-twitter-forms-platform-2020-04-20-13_24_41.png

--Check if an automatic reply is coming, and then interact with people on Twitter. In English. ** ** - If you haven't come, wait. I just wait. ** **

Other lessons

** ・ Read the policy properly ** ** ・ Do not use the DM function unless something goes wrong ** ** ・ The world of programmers should be recognized as basic English **

Page that was taken care of

How to unfreeze Twitter applications | Net BugyoHow to unfreeze Twitter application | 56stationTwitter API Write permission was frozen in summer 2019 --QiitaTwitter account, story of spending 7 days of uncomfortable New Year due to freezing of apps --Qiita

Recommended Posts

A story about a student who was spared due to the SARS-CoV-2 epidemic and finally made a Twitter App and finally hit the limit of the Twitter API
A story about hitting the League Of Legends API with JAVA
The story of forgetting to close a file in Java and failing
A story I was addicted to when testing the API using MockMVC
A memo about the types of Java O/R mappers and how to select them
Let's implement a function to limit the number of access to the API with SpringBoot + Redis