Gfycat

Learn how to add a GIF keyboard to your app using Gfycat

GIFs are a great way to change the tone or convey emotions in your conversations. Here is the guide which helps to implement Gfycat in an easy and quick way. Let's get started!

Settings

  1. Login to the CometChat Dashboard.
  2. Select one of your apps.
  3. On the Extensions page, enable Gfycat.

How does it work?

This extension uses the callExtension method provided by the CometChat Pro SDK. You can perform the following actions using this method:

  1. Get trending GIFs
  2. Search for GIFs

Get Trending GIFs

To list and show the most trending GIFs on Gfycat, all you have to do is include the following parameters in your request.

Key

Value

Description

cursor

string

This helps in getting the results as pages.

Initially, you can pass this as 0. Later, once you make the query and get a response, you can use the cursor value provided in the response.

Once you have set the above parameters, you can make a call to the extension as follows:

const URL = "v1/trending?cursor=0";
CometChat.callExtension('gifs-gfycat', 'GET', URL, null).then(response => {
    // GIFs data from Gfycat
})
.catch(error => {
    // Error occured
});
String URL = "/v1/trending?cursor=0";

CometChat.callExtension("gifs-gfycat", "GET", URL, null,
new CometChat.CallbackListener < JSONObject > () {
    @Override
    public void onSuccess(JSONObject jsonObject) {
        // GIFs data from Gfycat
    }
    @Override
    public void onError(CometChatException e) {
        // Some error occured
    }
});
CometChat.callExtension(slug: "gifs-gfycat", type: .get, endPoint: "/v1/trending?cursor=0", body: nil, onSuccess: { (response) in
        // GIFs data from Gfycat
      }) { (error) in
        // Some error occured
      }
    }

Search for GIFs

Apart from listing the trending ones, the extension also allows searching for a particular GIF using the following parameters:

Key

Value

Description

cursor

string

This helps in getting the results as pages.

Initially, you can pass this as 0. Later on, once you make the query and get a response, you can use the cursor value provided in the response.

query

string

Search term

Once you have all the above parameters, you can make a call to the extension as follows:

const URL = "v1/search?cursor=0&query=awesome";
CometChat.callExtension('gifs-gfycat', 'GET', URL, null).then(response => {
    // GIFs data from Gfycat
})
.catch(error => {
    // Error occured
});
String URL = "/v1/search?cursor=0&query=awesome";

CometChat.callExtension("gifs-gfycat", "GET", URL, null,
new CometChat.CallbackListener < JSONObject > () {
    @Override
    public void onSuccess(JSONObject jsonObject) {
        // GIFs data from Gfycat
    }
    @Override
    public void onError(CometChatException e) {
        // Some error occured
    }
});
CometChat.callExtension(slug: "gifs-gfycat", type: .get, endPoint: "/v1/search?cursor0&query=awesome", body: nil, onSuccess: { (response) in
        // GIFs data from gfycat
      }) { (error) in
        // Some error occured
      }
    }

Did this page help you?