Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/June911/twitter_giveway_bot
https://github.com/June911/twitter_giveway_bot
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/June911/twitter_giveway_bot
- Owner: June911
- Created: 2022-03-21T22:10:22.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-08T23:44:11.000Z (almost 3 years ago)
- Last Synced: 2024-08-03T01:15:15.051Z (5 months ago)
- Language: Python
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-dao-zh - Giveaway bot on Twitter with Twitter API V2 - Twitter 自动抽奖脚本 (社群经营)
README
## Giveaway bot on Twitter with Twitter API V2
setup steps:
1. create developer account at https://developer.twitter.com/en (I'm using the API V2 here, because V1 is not accessible)
2. go to the developer portal, then go to the User authentication settings, then make OAuth 1.0a on and click it "Read and write", put CallbakcURL "https://127.0.0.1" (local host, we don't use that, so doesn't matter)
3. go back to the developer portal, click the "Keys and tokens", generate "Access Token and Serect"
4. create a .env file, put your API_KEY, API_KEY_SECRET, ACCESS_TOKEN and ACCESS_TOKEN_SECRET
5. run "pip install -r requirements.txt"
6. you are ready to go !!!how does the scipt work ?
1. connect to twitter api server using Tweepy package
2. get all acounts that I followed
3. find their recent tweets
4. for every tweet, if at least one of the keywords list ("giveaway" ....) in the tweet, we consider it as giveway tweet. So we acts:
- follow all twitter accounts metionned
- like the tweet
- retweet
- reply/tag!!! don't give up when you don't get the expansions with API V2 client. becasue the print function would only the original strings.
we can access the user's follower by `xx["data"]["public_metrics"][followers_count]`
Explanation here: https://stackoverflow.com/questions/70371657/problem-with-getting-tweet-fields-from-twitter-api-2-0-using-tweepyuserful urls:
- https://docs.tweepy.org/en/stable/client.html
- https://github.com/tweepy/tweepy/tree/master/examples/API_v2
- https://docs.tweepy.org/en/v4.4.0/faq.html#why-am-i-not-getting-expansions-or-includes-data-with-api-v2-using-client