페이지 이동경로
  • Docs>
  • Message>
  • Kakao Talk sharing: JavaScript

Message

Kakao Talk sharing: JavaScript

This document describes how to integrate the Kakao Talk sharing APIs into your service with the Kakao SDK for JavaScript (hereinafter JavaScript SDK).

You can test the features described in this document in [Tools] > [JS SDK demo] menu.

Before you begin

Install SDK

Import the JavaScript SDK into your web page and initialize it by referring to Getting started > JavaScript.

Register Web Platform

To use the JavaScript SDK, you must register the Web platform in advance. Go to [My Application] > [Platform] and register your site domains.

Choose an API to use

According to your service's purpose and requirements, you need to decide which API to use first by considering their characteristics and difference.

Step 1. Select a type of Messaging API

There are two types of messaging APIs: Kakao Talk sharing API and Kakao Talk messaging API. You need to understand the differences between the two messaging APIs completely by referring to Understand concepts, and decide which API to use to implement the function to send a message.

Step 2. Select a message type and configuration method

Decide which message template to use by referring to Message template > Types.

You can configure a message according to the default template in JSON format or create a custom template in person for your service. Refer to Message configuration method for more details.

Step 3. Select an implementation method

When you implement the Kakao Talk sharing API with the JavaScript SDK, you can use two methods to call the API.

  • Using Kakao Talk sharing button: You can use the Kakao Talk sharing button provided by the JavaScript SDK by adding an event handler to the button. This is intended to request to send a Kakao Talk sharing message when a user clicks the Kakao Talk sharing button.
  • Using custom sharing button: You can dynamically implement a feature to send a Kakao Talk sharing message to the button you have created on your own. This is intended to request to send a message when a user clicks the share button that your service creates on the service web page internally without using the Kakao Talk sharing button.

APIs by conditions

According to the desired message type, the required components of the message and the function to call are different. Refer to Message template components and samples.

Message type Configuration method Implementation Method Function
Feed, List, Location, Commerce, Text Default template Send a message through Kakao Talk sharing button createDefaultButton()
Feed, List, Location, Commerce, Text Default template Send a message through your own button sendDefault()
Feed, List, Commerce Custom template Send a message through Kakao Talk sharing button createCustomButton()
Feed, List, Commerce Custom template Send a message through your own button createScrapButton()
Scrap Default template Send a message through Kakao Talk sharing button createScrapButton()
Scrap Default template Send a message through your own button sendScrap()
Scrap Custom template Send a message through Kakao Talk sharing button createScrapButton()
Scrap Custom template Send a message through your own button sendScrap()

Set Custom URL Scheme

Messages sent through Kakao Talk sharing include a link to open the specified web page or app. The buttons in the message launch the app through a Custom URL Scheme consisting of a URL scheme and parameters. If the app has not been installed on a user's device, the user is redirected to an Open market to download the app.

Set a URL scheme in "kakao${YOUR_NATIVE_APP_KEY}://kakaolink" format in advance to run an app by referring to the following guides:

You can also pass parameters additionally when running the app as needed by using androidExecutionParams for Android SDK and iosExecutionParams for iOS SDK. If you have defined the parameters, the following schemes are invoked when a user clicks the button in the Kakao Talk sharing message to launch the app.

kakao${YOUR_NATIVE_APP_KEY}://kakaolink?${androidExecutionParams}
kakao${YOUR_NATIVE_APP_KEY}://kakaolink?${iosExecutionParams}

Send message with default template

This API enables you to configure a message in JSON format according to the default template type to use and share it through Kakao Talk.

Using Kakao Talk sharing button

Add the Kakao.Link.createDefaultButton() function to the position where you want to display the Kakao Talk sharing button in your web page source code. When a user clicks the button, the request to send a message is invoked.

Parameter
Name Type Description Required
container String ID of the element where the [Share] button is added. O
- DefaultFeedSettings
DefaultListSettings
DefaultLocationSettings
DefaultCommerceSettings
DefaultTextSettings
Object of the message template to be sent. O
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Feed
List
Location
Commerce
Text
Kakao.Link.createDefaultButton({
  container: '#kakao-link-btn',
  objectType: 'feed',
  content: {
    title: 'Dessert pictures',
    description: 'Americano, bread, cake',
    imageUrl:
      'https://mud-kage.kakao.com/dn/NTmhS/btqfEUdFAUf/FjKzkZsnoeE4o19klTOVI1/openlink_640x640s.jpg',
    link: {
      mobileWebUrl: 'https://developers.kakao.com',
      androidExecutionParams: 'test',
    },
  },
  itemContent:{
    profileText: 'Kakao',
    profileImageUrl: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
    titleImageUrl: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
    titleImageText: 'Cheese cake',
    titleImageCategory: 'cake',
    items: [
      {
        item: 'cake1',
        itemOp: '1000 won',
      },
      {
        item: 'cake2',
        itemOp: '2000 won',
      },
      {
        item: 'cake3',
        itemOp: '3000 won',
      }
    ],
    sum: 'Total',
    sumOp: '3000 won',
  },
  social: {
    likeCount: 10,
    commentCount: 20,
    sharedCount: 30,
  },
  buttons: [
    {
      title: 'View on Web',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'View on App',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
      },
    },
  ]
});
Kakao.Link.createDefaultButton({
  container: '#kakao-link-btn',
  objectType: 'list',
  headerTitle: 'WEEKLY MAGAZINE',
  headerLink: {
    mobileWebUrl: 'https://developers.kakao.com',
    webUrl: 'https://developers.kakao.com',
  },
  contents: [
    {
      title: 'My hobby, Table tennis',
      description: 'Sports',
      imageUrl:
        'http://k.kakaocdn.net/dn/bDPMIb/btqgeoTRQvd/49BuF1gNo6UXkdbKecx600/kakaolink40_original.png',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'Story about coffee with cream',
      description: 'Food',
      imageUrl:
        'http://k.kakaocdn.net/dn/QPeNt/btqgeSfSsCR/0QJIRuWTtkg4cYc57n8H80/kakaolink40_original.png',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'Inspiring pictures',
      description: 'Photo',
      imageUrl:
        'http://k.kakaocdn.net/dn/c7MBX4/btqgeRgWhBy/ZMLnndJFAqyUAnqu4sQHS0/kakaolink40_original.png',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
  buttons: [
    {
      title: 'View on Web',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'View on App',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
});
Kakao.Link.createDefaultButton({
  container: '#kakao-link-btn',
  objectType: 'location',
  address: '235, Pangyoyeok-ro, Bundang-gu, Seongnam-si, Gyeonggi-do',
  addressTitle: 'Kakao Pangyo Office Cafe Talk',
  content: {
    title: 'New menu release❤️ Cherry Blossom Latte',
    description: 'Cherry blossom latte 1+1 for this week',
    imageUrl:
      'http://k.kakaocdn.net/dn/bSbH9w/btqgegaEDfW/vD9KKV0hEintg6bZT4v4WK/kakaolink40_original.png',
    link: {
      mobileWebUrl: 'https://developers.kakao.com',
      webUrl: 'https://developers.kakao.com',
    },
  },
  social: {
    likeCount: 286,
    commentCount: 45,
    sharedCount: 845,
  },
  buttons: [
    {
      title: 'View on Web',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
});
Kakao.Link.createDefaultButton({
  container: '#kakao-link-btn',
  objectType: 'commerce',
  content: {
    title:
        'Here is the story of Kakao Mini. You can make your daily life more enjoyable and more convenient with Kakao Mini. Call Hey Ryan anytime, anywhere.',
    imageUrl:
      'http://k.kakaocdn.net/dn/dScJiJ/btqB3cwK1Hi/pv5qHVwetz5RZfPZR3C5K1/kakaolink40_original.png',
    link: {
      mobileWebUrl: 'https://developers.kakao.com',
      webUrl: 'https://developers.kakao.com',
    },
  },
  commerce: {
    productName: 'Kakao Mini',
    regularPrice: 100000,
    discountRate: 10,
    discountPrice: 90000
  },
  buttons: [
    {
      title: 'Purchase',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'Share',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
});
Kakao.Link.createDefaultButton({
  container: '#kakao-link-btn',
  objectType: 'text',
  text:
    'The Text template provided as a default template can contain text up to 200 characters. The Text template has a text area and a default button. You can also add an additional button. If you use the Kakao Talk sharing, you can send a message with a more extended form of templates, such as sending multiple images and profile information.',
  link: {
    mobileWebUrl:
      'https://developers.kakao.com',
    webUrl:
      'https://developers.kakao.com',
  },
});

Using custom sharing button

To use the customized sharing button for your service, call the Kakao.Link.sendDefault() function. Unlike Kakao.Link.createDefaultButton(), Kakao.Link.sendDefault() does not add a Kakao Talk sharing button but only requests to send a message. This function is invoked when a user clicks the custom sharing button.

Parameter
Name Type Description Required
- DefaultFeedSettings
DefaultListSettings
DefaultLocationSettings
DefaultCommerceSettings
DefaultTextSettings
Object of the message template to be sent. O
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Feed
List
Location
Commerce
Text
Kakao.Link.sendDefault({
  objectType: 'feed',
  content: {
    title: 'Dessert pictures',
    description: 'Americano, bread, cake',
    imageUrl:
      'https://mud-kage.kakao.com/dn/NTmhS/btqfEUdFAUf/FjKzkZsnoeE4o19klTOVI1/openlink_640x640s.jpg',
    link: {
      mobileWebUrl: 'https://developers.kakao.com',
      androidExecutionParams: 'test',
    },
    itemContent:{
      profileText: 'Kakao',
      profileImageUrl: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
      titleImageUrl: 'http://k.kakaocdn.net/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png',
      titleImageText: 'Cheese cake',
      titleImageCategory: 'cake',
      items: [
        {
          item: 'cake1',
          itemOp: '1000 won',
        },
        {
          item: 'cake2',
          itemOp: '2000 won',
        },
        {
          item: 'cake3',
          itemOp: '3000 won',
        }
      ],
      sum: 'Total',
      sumOp: '3000 won',
  },
  social: {
    likeCount: 10,
    commentCount: 20,
    sharedCount: 30,
  },
  buttons: [
    {
      title: 'View on Web',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'View on App',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
      },
    },
  ]
});
Kakao.Link.sendDefault({
  objectType: 'list',
  headerTitle: 'WEEKLY MAGAZINE',
  headerLink: {
    mobileWebUrl: 'https://developers.kakao.com',
    webUrl: 'https://developers.kakao.com',
  },
  contents: [
    {
      title: 'My hobby, Table tennis',
      description: 'Sports',
      imageUrl:
        'http://k.kakaocdn.net/dn/bDPMIb/btqgeoTRQvd/49BuF1gNo6UXkdbKecx600/kakaolink40_original.png',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'Story about coffee with cream',
      description: 'Food',
      imageUrl:
        'http://k.kakaocdn.net/dn/QPeNt/btqgeSfSsCR/0QJIRuWTtkg4cYc57n8H80/kakaolink40_original.png',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'Inspiring pictures',
      description: 'Photo',
      imageUrl:
        'http://k.kakaocdn.net/dn/c7MBX4/btqgeRgWhBy/ZMLnndJFAqyUAnqu4sQHS0/kakaolink40_original.png',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
  buttons: [
    {
      title: 'View on Web',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'View on App',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
});
Kakao.Link.sendDefault({
  objectType: 'location',
  address: '235, Pangyoyeok-ro, Bundang-gu, Seongnam-si, Gyeonggi-do',
  addressTitle: 'Kakao Pangyo Office Cafe Talk',
  content: {
    title: 'New menu release❤️ Cherry Blossom Latte',
    description: 'Cherry blossom latte 1+1 for this week',
    imageUrl:
      'http://k.kakaocdn.net/dn/bSbH9w/btqgegaEDfW/vD9KKV0hEintg6bZT4v4WK/kakaolink40_original.png',
    link: {
      mobileWebUrl: 'https://developers.kakao.com',
      webUrl: 'https://developers.kakao.com',
    },
  },
  social: {
    likeCount: 286,
    commentCount: 45,
    sharedCount: 845,
  },
  buttons: [
    {
      title: 'View on Web',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
});
Kakao.Link.sendDefault({
  objectType: 'commerce',
  content: {
    title:
      'Here is the story of Kakao Mini. You can make your daily life more enjoyable and more convenient with Kakao Mini. Call Hey Ryan anytime, anywhere.',
    imageUrl:
      'http://k.kakaocdn.net/dn/dScJiJ/btqB3cwK1Hi/pv5qHVwetz5RZfPZR3C5K1/kakaolink40_original.png',
    link: {
      mobileWebUrl: 'https://developers.kakao.com',
      webUrl: 'https://developers.kakao.com',
    },
  },
  commerce: {
    productName: 'Kakao Mini',
    regularPrice: 100000,
    discountRate: 10,
    discountPrice: 90000
  },
  buttons: [
    {
      title: 'Purchase',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
    {
      title: 'Share',
      link: {
        mobileWebUrl: 'https://developers.kakao.com',
        webUrl: 'https://developers.kakao.com',
      },
    },
  ],
});
Kakao.Link.sendDefault({
  objectType: 'text',
  text:
    'The Text template provided as a default template can contain text up to 200 characters. The Text template has a text area and a default button. You can also add an additional button. If you use the Kakao Talk sharing, you can send a message with a more extended form of templates, such as sending multiple images and profile information.',
  link: {
    mobileWebUrl:
      'https://developers.kakao.com',
    webUrl:
      'https://developers.kakao.com',
  },
});

Send message with custom template

This API enables you to customize a template in [Tools] > [Message Template Builder] and send a message through Kakao Talk.

Using Kakao Talk sharing button

Add the Kakao.Link.createCustomButton() function to the position where you want to display the Kakao Talk sharing button in your web page source code. When a user clicks the button, the request to send a message is invoked.

Parameter
Name Type Description Required
container String ID of the element where the [Share] button is added. O
templateId Number Template ID of the custom template registered in [Tools] > [Message Template Builder].
Refer to Message template builder.
O
templateArgs Object If the specified template contains a user argument, use this parameter to pass key-value pairs.
You cannot overwrite the scrap result.
X
callback Function(Object) Callback function that gets invoked when the Kakao Talk sharing message is successfully sent on the Desktop environment.
NOTE: Not support Internet Explore.
X
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Kakao.Link.createCustomButton({
  container: '#kakao-link-btn',
  templateId: ${YOUR_TEMPLATE_ID},
  templateArgs: {
    'title': 'This is the title area.',
    'description': 'This is the description area.'
  }
});

Using custom sharing button

To use the customized sharing button for your service, call the Kakao.Link.sendCustom() function. Unlike the Kakao.Link.createCustomButton() function, the Kakao.Link.sendCustom() function does not add a Kakao Talk sharing button but only requests to send a message. This function is invoked when a user clicks the custom sharing button.

Parameter
Name Type Description Required
templateId Number Template ID of the custom template registered in [Tools] > [Message Template Builder].
Refer to Message template builder.
O
templateArgs Object If the specified template contains a user argument, use this parameter to pass key-value pairs.
You cannot overwrite the scrap result.
X
callback Function(Object) Callback function that gets invoked when the Kakao Talk sharing message is successfully sent on the Desktop environment.
NOTE: Not support Internet Explore.
X
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Kakao.Link.sendCustom({
  templateId: ${YOUR_TEMPLATE_ID},
  templateArgs: {
    'title': 'This is the title area.',
    'description': 'This is the description area.'
  }
});

Send scrap message with default template

This API scraps a web page, configures a message based on the scraped web page information, and then sends it through Kakao Talk.

Using Kakao Talk sharing button

Add the Kakao.Link.createScrapButton() function to the position where you want to display the Kakao Talk sharing button in your web page source code. When a user clicks the button, the request to send a message is invoked.

Parameter
Name Type Description Required
container String ID of the element where the [Share] button is added. O
requestUrl String Web page URL to be scraped.
The link is created based on the web page metadata.
Its domain must match the domain registered on the Kakao Developers.
O
templateArgs Object If the specified template contains a user argument, use this parameter to pass key-value pairs.
You cannot overwrite the scrap result.
X
callback Function(Object) Callback function that gets invoked when the Kakao Talk sharing message is successfully sent on the Desktop environment.
NOTE: Not support Internet Explore.
X
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Kakao.Link.createScrapButton({
  container: '#kakao-link-btn',
  requestUrl: 'https://developers.kakao.com'
});

Using custom sharing button

To use the customized sharing button for your service, call the Kakao.Link.sendScrap() function. Unlike the Kakao.Link.createScrapButton() function, the Kakao.Link.sendScrap() function does not add a Kakao Talk sharing button but only requests to send a message. This function is invoked when a user clicks the custom sharing button.

Parameter
Name Type Description Required
requestUrl String Web page URL to be scraped.
The link is created based on the web page metadata.
Its domain must match the domain registered on the Kakao Developers.
O
templateArgs Object If the specified template contains a user argument, use this parameter to pass key-value pairs.
You cannot overwrite the scrap result.
X
callback Function(Object) Callback function that gets invoked when the Kakao Talk sharing message is successfully sent on the Desktop environment.
NOTE: Not support Internet Explore.
X
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Kakao.Link.sendScrap({
  requestUrl: 'https://developers.kakao.com'
});

Send scrap message with custom template

This API scraps a web page, configures a message based on the scraped web page information, and then sends it through Kakao Talk. You can use a custom template registered in [Tools] > [Message Template Builder] when requesting to send a scrap message.

Using Kakao Talk sharing button

Add the Kakao.Link.createScrapButton() function to the position where you want to display the Kakao Talk sharing button in your web page source code. When a user clicks the button, the request to send a message is invoked.

Parameter
Name Type Description Required
container String ID of the element where the [Share] button is added. O
requestUrl String Web page URL to be scraped.
The link is created based on the web page metadata.
Its domain must match the domain registered on the Kakao Developers.
O
templateId Number Used when you want to send a scrap message with the template registered in [Tools] > [Message Template Builder].
Specify the ID of the template to apply.
When you use this parameter, the scraped content is applied in the template with the specified templateId.
O
templateArgs Object If the specified template contains a user argument, use this parameter to pass key-value pairs.
You cannot overwrite the scrap result.
X
callback Function(Object) Callback function that gets invoked when the Kakao Talk sharing message is successfully sent on the Desktop environment.
NOTE: Not support Internet Explore.
X
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Kakao.Link.createScrapButton({
  container: '#kakao-link-btn',
  requestUrl: 'https://developers.kakao.com',
  templateId: ${YOUR_TEMPLATE_ID}
});

Using custom sharing button

To use the customized sharing button for your service, call the Kakao.Link.sendScrap() function. Unlike the Kakao.Link.createScrapButton() function, the Kakao.Link.sendScrap() function does not add a Kakao Talk sharing button but only requests to send a message. This function is invoked when a user clicks the custom sharing button.

Parameter
Name Type Description Required
requestUrl String Web page URL to be scraped.
The link is created based on the web page metadata.
Its domain must match the domain registered on the Kakao Developers.
O
templateId Number Used when you want to send a scrap message with the template registered in [Tools] > [Message Template Builder].
Specify the ID of the template to apply.
When you use this parameter, the scraped content is applied in the template with the specified templateId.
O
templateArgs Object If the specified template contains a user argument, use this parameter to pass key-value pairs.
You cannot overwrite the scrap result.
X
callback Function(Object) Callback function that gets invoked when the Kakao Talk sharing message is successfully sent on the Desktop environment.
NOTE: Not support Internet Explore.
X
serverCallbackArgs Object Used when you want to get a callback from Kakao to your service server when a message is successfully sent.
Since the Kakao Talk sharing API does not inform the result of message delivery, it is recommended to implement Kakao Talk sharing success callback.
X
Sample
Kakao.Link.sendScrap({
  requestUrl: 'https://developers.kakao.com',
  templateId: ${YOUR_TEMPLATE_ID}
});

Set Kakao Talk sharing success callback

The Kakao Talk sharing success callback is a function to send a callback request to the URL specified on Kakao Developers when a Kakao Talk sharing message is successfully sent to friends or a chatroom selected by a user. This function is only available for Kakao Talk sharing API, not for Kakao Talk messaging API.

To use this feature, you need to:

  1. Set the callback URL and request method by referring to Prerequisites > Set Kakao Talk sharing success callback.
  2. Build a server to receive a Kakao Talk sharing success callback.
  3. Set a custom parameter to pass additional information when requesting the Kakao Talk sharing API.
  4. Implement a process to handle the callback delivered to your service server's callback URL.

To use the Kakao Talk sharing success callback function, you must specify a custom parameter through serverCallbackArgs. Otherwise, you cannot receive Kakao Talk sharing success callbacks even though you registered a callback URL for Kakao Talk sharing in [My Application]. When your service server receives a Kakao Talk sharing success callback, you can figure out additional information through the predefined custom parameters, such as what content the user has shared.

To pass additional information when requesting the Kakao Talk sharing API, pass keys and values through serverCallbackArgs. Here is a code snippet showing how to set the custom parameter for the Kakao Talk sharing success callback.

// The Kakao Talk sharing success callback is sent to the specified callback URL when a Kakao Talk sharing message is successfully sent.
Kakao.Link.sendDefault({
  objectType: 'text',
  text: 'Start developing the Kakao platform services with the JavaScript SDK sample.',
  link: {
    mobileWebUrl: 'https://developers.kakao.com',
    webUrl: 'https://developers.kakao.com'
  },
  serverCallbackArgs: { // Set custom parameter.
    key: 'value'
  }
});

If the Kakao Talk sharing message is successfully sent, Kakao sends a Kakao Talk sharing success callback including the specified parameters to the callback URL of your service server. For more information on the callback request, refer to Reference Information > Kakao Talk sharing success callback.

Upload image

You can attach images to the Kakao Talk message when configuring a message template in the form of a URL or upload images in the Message Template Builder in advance. To attach the image file stored on your device to a message, you must upload the image file to the server first to obtain its URL value.

If it is difficult to obtain the image file URL, you can either upload an image file of the web page to the Kakao Talk sharing server or scrap it. You can only upload an image with a file size of 2 MB or less. The images uploaded to the Kakao Talk sharing server are stored for up to 20 days and automatically deleted after the period.

Uploading image

Parameter
Name Type Description Required
file FileList URL of the image to be uploaded. O
Sample
var files = document.getElementById('file').files;

Kakao.Link.uploadImage({
  file: files
}).then(function(res){
  document.getElementById('uploadUrl').value = res.infos.original.url;
});
Return data

When the request is successful, the information of the uploaded image is returned.

ImageInfos
Name Type Description Required
original Object The original image information. O
original
Name Type Description Required
url String URL of the uploaded image. O
content_type String Format of the uploaded image. O
length Number File size of the uploaded image in bytes. O
width Number Width of the uploaded image in pixels. O
height Number Height of the uploaded image in pixels. O

Scraping image

Parameter
Name Type Description Required
imageUrl String URL of the image to be scrapped. O
var url = document.getElementById('url').value;

Kakao.Link.scrapImage({
  imageUrl: url
}).then(function(res){
  document.getElementById('scrapUrl').value = res.infos.original.url;
});
Return data

When the request is successful, the information of the uploaded image is returned through ImageInfos.

Deleting image

You can also delete the image uploaded in the Kakao Talk sharing server by calling deleteImage().

Parameter
Name Type Description Required
imageUrl String URL of the image to be deleted. O
var url = document.getElementById('url').value;

Kakao.Link.deleteImage({
  imageUrl: url
});

See more