I've had more opportunities to use GAE (python) for work since last month, but I haven't tried to make a proper app using GAE (python) from scratch (there was only a guestbook listed in helloworld and official tutorials). ). So, I decided to make a Twitter BOT (because I didn't understand the batch function).
The content is a BOT that automatically posts the names of other summoners who have participated in the recent matches of registered users on Twitter in a famous overseas game called League of Legends. Twitter's OAuth authentication uses tweepy, and League of Legends match results and summoner names are obtained using the RIOT API and the results are stored in ndb.
--Use Tweepy to authenticate Twitter with OAuth, and then store information such as Twitter access token in modelUser. -Register your own summoner name on the / registration form screen, and store the summoner name, account Id, etc. obtained via the RIOT API in modelTask. --Using taskqueue (push), pull the name of the summoner who participated in the latest match from the API using the accountId included in the modelTask, and have only 4 participants automatically posted on Twitter.
However, ** There are few GAE (python) implementation examples that can be used as a reference when implementing the above items, or even if there are, there are many cases where the version etc. is too old to work, so I had a lot of trouble. So, this time, I have posted ** more reference URLs ** in the references ...! For the time being, I intend to cover all the places I stumbled upon, so I hope you will find it helpful.
Also, ** the source code and usage of the actual finished product are posted on Github **, so if you want to check the behavior for the time being, please refer to the README on Github and use it for studying.
"** Main sites that I referred to when creating this BOT **" Create a Twitter BOT service with GAE / P + Tweepy + RIOT API! (Part 1)
Create a Twitter BOT service with GAE / P + Tweepy + RIOT API! (Part 2)
I tried to get the account information with riot api
"** How to get access keys for Twitter and RIOT API **" [Summary of procedures from Twitter API registration (account application method) to approval * Information as of August 2019](https://qiita.com/kngsym2018/items/2524d21455aac111cdee#consumer-api-keys%E3%82 % A2% E3% 82% AF% E3% 82% BB% E3% 82% B9% E3% 83% 88% E3% 83% BC% E3% 82% AF% E3% 83% B3% E6% 83% 85 % E5% A0% B1% E3% 82% 92% E4% BD% BF% E7% 94% A8% E3% 81% 97% E3% 81% 9Fpython% E3% 82% B9% E3% 82% AF% E3 % 83% AA% E3% 83% 97% E3% 83% 88)
I tried to get the account information with riot api
"** The site I saw when I struggled with how to install Tweepy **" Create a Twitter Bot for Google App Engine with Flask and Tweepy
"** Tips on how to deploy a third-party python library on GAE **" How to use a third party library on Google App Engine (Python)
Causes and solutions for "ImportError: No module named _winreg" on GAE / Py
[Stack overflow shows that if you don't put setup.cfg, you will get an error even if you pip install in the lib folder](https://stackoverflow.com/questions/24257803/distutilsoptionerror-must-supply-either- home-or-prefix-exec-prefix-not-both)
[List of third-party libraries built into GAE (libraries that can be included in app.yaml)](https://cloud.google.com/appengine/docs/standard/python/tools/built-in-libraries- 27)
[Please refer to here for those who want to pip install by writing in requirement.txt](https://datumstudio.jp/blog/gae%E3%81%A7%E3%82%B5%E3%82 % AF% E3% 83% 83% E3% 81% A8api% E3% 82% B5% E3% 83% BC% E3% 83% 90% E6% A7% 8B% E7% AF% 89)
"** Sites that helped me when I struggled to implement **" Requests-related behavior errors can be resolved by including requests_toolbelt.adapters.appengine
URL referred to when practicing Tweepy's OAuth1a authentication
"** Those who want to know about Twitter OAuth authentication **" The most easy-to-understand explanation of OAuth Authentication technology you should know in application development --OAuth 1.0 + OAuth 2.0 + OpenID Connect-
This time, I created a Twitter BOT using GAE (python). Since there weren't many implementation examples, I was struggling with the official reference for the task queue and detailed specifications around ndb, but I managed to implement it.
If you have a chance to use GAE (python) for work or hobby, please refer to this and proceed with the implementation to deepen your understanding. Please use it for training (please add a star when cloning from Github!)
--Routing should have been combined into one file in routes.py --Maybe I could have used memcache ――I wanted to clean the front screen --Understanding around ndb was less than I expected
Recommended Posts