Created
October 13, 2023 21:00
-
-
Save stefanbohacek/91715b59543c686bc22e99c888408367 to your computer and use it in GitHub Desktop.
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
(async () => { | |
const domain = "..."; | |
const token = "..."; | |
const postUrl = "..."; | |
let response; | |
response = await fetch( | |
`https://${domain}/authorize_interaction?uri=${postUrl}`, | |
{ | |
headers: { | |
"content-type": "application/json", | |
authorization: `Bearer ${token}`, | |
}, | |
body: null, | |
credentials: "include", | |
} | |
); | |
const localPostURL = response.url; | |
const localPostID = localPostURL.split("/").slice(-1); | |
console.log({ localPostURL, localPostID }); | |
response = await fetch( | |
`https://${domain}/api/v1/statuses/${localPostID}/reblog`, | |
{ | |
headers: { | |
"content-type": "application/json", | |
authorization: `Bearer ${token}`, | |
}, | |
body: null, | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
} | |
); | |
response = await response.json(); | |
console.log("reblog", response); | |
response = await fetch( | |
`https://${domain}/api/v1/statuses/${response.id}/pin`, | |
{ | |
headers: { | |
"content-type": "application/json", | |
authorization: `Bearer ${token}`, | |
}, | |
body: null, | |
method: "POST", | |
mode: "cors", | |
credentials: "include", | |
} | |
); | |
response = await response.json(); | |
console.log("pin", response); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment