Get a DirectChat pin

This page will explain how to let a user of your application receive a DirectChat pin. A couple of steps are required and shown below.

  1. Implement our SDK.
  2. Call the "DirectChat" function in our SDK.
  3. Obtain the DirectChat Pin.

 

 

Implement our SDK

Implementing our SDK is easy. Include the Javascript SDK on your page once, ideally right after the <body> openingtag.

<script>(function (d, s, id) { var js, ajs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = '//cdn.adultwork.com/platform/sdk/sdk.js#APIKey={your-api-key}&clientId={your-clientid}'; ajs.parentNode.insertBefore(js, ajs); }(document, 'script', 'adultwork-jssdk'));</script>
  • {your-api-key}
    • The api key of your project. This can be found in the project's details page.
  • {your-clientid}
    • The client identifier. This can be found in the project's details page under the Unified Login tab.

 

 

Call the "DirectChat" function in our SDK.

Once the reference is made with our sdk as described in Implement our SDK you can call the "DirectChat" function quite easy.

<script>	
	function getPin(){
		var url = 'https://platform.adultwork.com/DirectChat/GetPIN';
		var userId = 123456;
		var clientId = 'A1B2C3D4E5F6';
		
		AW.DirectChat.init(url, userId, 'en-GB', clientId);
		AW.DirectChat.directchat_window(onClose);	
	}	

	function onClose(){
		// optional on close callback function.
	}	
</script>
  • url
    • The URL of our DirectChat functionality in the platform. This value must be set to 'https://platform.adultwork.com/DirectChat/GetPIN'.
  • userId
    • The user id of DirectChat user.
  • clientId
    • The client identifier. This can be found in the project's details page under the Unified Login tab.
  • onClose
    • Optional callback function which the SDK will call when the pop-up closes.

 

 

Obtain the DirectChat Pin.

Assuming the user was logged in the platform popup will show the pin as well as the price in the window.