summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/twitter.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-05 08:00:10 +0200
committerRaindropsSys <contact@minteck.org>2023-04-05 08:00:10 +0200
commit164d31aeb4d1e4d4b796fa4c5fbc356ab1a6ad67 (patch)
tree2675cb1d904c0775ae23f0c93f724419107e787b /includes/external/addressbook/twitter.js
parentb9aca19cccf9fd85a05d2ae32846b5b4f25a4dc1 (diff)
downloadpluralconnect-164d31aeb4d1e4d4b796fa4c5fbc356ab1a6ad67.tar.gz
pluralconnect-164d31aeb4d1e4d4b796fa4c5fbc356ab1a6ad67.tar.bz2
pluralconnect-164d31aeb4d1e4d4b796fa4c5fbc356ab1a6ad67.zip
Added 2 files (automated)
Diffstat (limited to 'includes/external/addressbook/twitter.js')
-rw-r--r--includes/external/addressbook/twitter.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/includes/external/addressbook/twitter.js b/includes/external/addressbook/twitter.js
new file mode 100644
index 0000000..b22fca3
--- /dev/null
+++ b/includes/external/addressbook/twitter.js
@@ -0,0 +1,62 @@
+const axios = require('axios');
+const apiVersion = "2";
+const app = require('../../app.json');
+
+function sleep(ms) {
+ return new Promise((res) => {
+ setTimeout(res, ms);
+ });
+}
+
+(async () => {
+ let user = process.argv[2];
+
+ try {
+ let data = (await axios.get(`https://api.twitter.com/${apiVersion}/users/${user}?user.fields=id,description,profile_image_url`, {
+ headers: {
+ Authorization: `Bearer ${app.twitter.bearer}`
+ }
+ })).data.data;
+
+ let obj = {
+ error: null,
+ avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/twitter.png",
+ name: data['name'],
+ description: `@${data['username']}`,
+ copy: [
+ {
+ title: "Copy link to profile",
+ text: `https://twitter.com/${data['username']}`
+ },
+ {
+ title: "Copy username",
+ text: `@${data['username']}`
+ },
+ {
+ title: "Copy ID",
+ text: `${data['id']}`
+ },
+ data['profile_image_url'] ? {
+ title: "Copy avatar URL",
+ text: data['profile_image_url']
+ } : null
+ ]
+ }
+
+ if (data['profile_image_url']) {
+ obj.avatar = data['profile_image_url'];
+ }
+
+ console.log(JSON.stringify(obj, null, 2));
+ } catch (e) {
+ console.log(JSON.stringify({
+ error: e,
+ avatar: "https://img.icons8.com/fluency-systems-regular/64/ffffff/twitter.png",
+ name: user,
+ description: "Twitter",
+ copy: []
+ }, null, 2));
+ }
+
+
+})(); \ No newline at end of file