-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch tweets related to external_custom (#533)
- Loading branch information
1 parent
a861475
commit 7d50e4b
Showing
4 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
node_modules |
This file contains 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
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(); | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
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" | ||
} | ||
} |