Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanbohacek/91715b59543c686bc22e99c888408367 to your computer and use it in GitHub Desktop.
Save stefanbohacek/91715b59543c686bc22e99c888408367 to your computer and use it in GitHub Desktop.
(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