Skip to content

Commit

Permalink
Fetch tweets related to external_custom (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
SAY-droid427 authored Aug 16, 2021
1 parent a861475 commit 7d50e4b
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Tweetest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
node_modules
44 changes: 44 additions & 0 deletions Tweetest/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const needle = require('needle');
require('dotenv').config()
const token = process.env.BEARER_TOKEN;

const endpointUrl = "https://api.twitter.com/2/tweets/search/recent";

async function getRequest() {


const params = {
'query': '#tests'
}

const res = await needle('get', endpointUrl, params, {
headers: {
"User-Agent": "v2RecentSearchJS",
"authorization": `Bearer ${token}`
}
})

if (res.body) {
return res.body;
} else {
throw new Error('Unsuccessful request');
}
}

(async () => {

try {
// Make request
const response = await getRequest();
console.log(response.data)
// For extracting github_url, repo name and test command from tweet
response.data.forEach((item)=>{
console.log(item)
})

} catch (e) {
console.log(e);
process.exit(-1);
}
process.exit();
})();
109 changes: 109 additions & 0 deletions Tweetest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Tweetest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "tweetest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "Apache License Version 2.0",
"dependencies": {
"needle": "^2.8.0"
}
}

0 comments on commit 7d50e4b

Please sign in to comment.