Can anyone help me work with Rebrandly API?
(you can see the API list here: https://developers.rebrandly.com/docs
I want to shorten the URL of my dynamic page once the form is submitted.
Is it possible?
If so, is there any chance someone will explain to me how?
Here is an example from their site how to use:
let linkRequest = {
destination: "https://www.youtube.com/channel/UCHK4HD0ltu1-I212icLPt3g",
domain: { fullName: "rebrand.ly" }
//, slashtag: "A_NEW_SLASHTAG"
//, title: "Rebrandly YouTube channel"
}
let requestHeaders = {
"Content-Type": "application/json",
"apikey": "YOUR_API_KEY",
"workspace": "YOUR_WORKSPACE_ID"
}
$.ajax({
url: "https://api.rebrandly.com/v1/links",
type: "post",
data: JSON.stringify(linkRequest),
headers: requestHeaders,
dataType: "json",
success: (link) => {
console.log(`Long URL was ${link.destination}, short URL is ${link.shortUrl}`);
}
});
To expose your site to their API you can use either Wix Fetch or Wix HTTP Functions.
https://www.wix.com/corvid/reference/wix-fetch.html
https://support.wix.com/en/article/corvid-accessing-third-party-services-with-the-fetch-api
https://www.wix.com/corvid/reference/wix-http-functions.html
https://support.wix.com/en/article/corvid-exposing-a-site-api-with-http-functions
You can see an example here that you can look over in your own Wix Editor.
https://www.wix.com/corvid/forum/community-discussion/example-myapi-and-myapiclient
https://www.wix.com/corvid/example/exposing-apis