Bitly
Learn how to minify the long website links in your text messages using Bitly.
Before you begin
- Sign up with Bitly.
- Once you have logged in, click on the Account name displayed in the top right corner.
- Click on Settings and in the left navigation pane, select API.
- Click on Generate Token to create a new Access Token.
- Using the above Access Token, fetch the GUID for your group using their Get Groups API.
- The Access Token and Bitly Group's GUID are required in extension settings.
Extension settings
- Login to CometChat and select your app.
- Go to the Extensions section and enable the Bitly extension.
- Open the settings for this extension.
- Enter your Bitly Access Token and Group's GUID.
- Save your settings.
How does it work?
This extension uses the callExtension
method provided by the CometChat SDK.
You can call the extension as follows:
- Javascript
- Java
- Swift
CometChat.callExtension("url-shortener-bitly", "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-bitly", "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-bitly", 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
}
}