Created
June 7, 2018 04:21
-
-
Save adin234/9826b9e73b66af332d76b725be9a28c8 to your computer and use it in GitHub Desktop.
use https://oauth.io/ to get your app id <3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script type="text/javascript" src="https://rawgit.com/oauth-io/oauth-js/master/dist/oauth.min.js"></script> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| OAuth.initialize(<Oauth.io application>) | |
| OAuth.popup('twitter').done(function(result) { | |
| getJunkSaisTweets(result); | |
| }); | |
| const baseurl = 'https://api.twitter.com/1.1/search/tweets.json?q=junksais&count=100'; | |
| const postSomething = (oauth, user, statusId) => { | |
| oauth.post('https://api.twitter.com/1.1/statuses/update.json', { | |
| data: { | |
| status: `@${user} #givesaisachance - ${generateRandom()}`, | |
| in_reply_to_status_id: statusId | |
| } | |
| }); | |
| }; | |
| const getJunkSaisTweets = (oauth, maxId) => { | |
| let requestUrl = baseurl; | |
| if (maxId) { | |
| requestUrl += `&max_id=${maxId}`; | |
| } | |
| oauth.get(requestUrl, { | |
| success: replyToTweets.bind(this, oauth) | |
| }); | |
| }; | |
| const generateRandom = () => { | |
| return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); | |
| }; | |
| const replyToTweets = (oauth, result) => { | |
| result.statuses.forEach((status) => { | |
| postSomething(oauth, status.user.screen_name, status.id_str); | |
| }); | |
| getJunkSaisTweets(oauth, result.statuses.pop().id_str); | |
| }; | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment