TinyURL
Learn how to minify the long website links in your text messages using TinyURL.
Before you begin
- Sign up with TinyURL
- Once you have logged in, click on Account in the top right corner.
- In the left navigation pane, select API.
- Create an API Token by giving it a name and permission to Create TinyURL.
- Make note of the API Token as it will be required in Extension's settings.
Extension settings
- Login to CometChat and select your app.
- Go to the Extensions section and enable the TinyURL extension.
- Open the settings and enter the TinyURL API Token.
- If you have chosen a paid plan, you can also save your BYO domain or subdomain. Default is set to
tinyurl.com
- Save your settings.
BYO Domain
If you don't plan on using a custom domain, please save tinyurl.com
as the default value here.
How does it work?
This extension uses the callExtension
method provided by CometChat SDK. You can call the extension as follows:
- Javascript
- Java
- Swift
CometChat.callExtension("url-shortener-tinyurl", "POST", "v1/shorten", {
text: "Your message with URL https://yourdomain.com/very/very/long/url",
})
.then((response) => {
// minifiedText in response
})
.catch((error) => {
// Error occured
});
String URL = "/v1/shorten";
JSONObject body=new JSONObject();
body.put("text", "Your message with URL https://yourdomain.com/very/very/long/url");
CometChat.callExtension("url-shortener-tinyurl", "POST", URL, body,
new CometChat.CallbackListener < JSONObject > () {
@Override
public void onSuccess(JSONObject jsonObject) {
// minifiedText from the extension
}
@Override
public void onError(CometChatException e) {
// Some error occured
}
});
CometChat.callExtension(slug: "url-shortener-tinyurl", type: .post, endPoint: "v1/shorten", body: ["text": "Your message with URL https://yourdomain.com/very/very/long/url"], onSuccess: { (response) in
// minifiedText from the extension
}) { (error) in
// Some error occured
}
}