Buy a movie

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

  1. Implement our SDK.
  2. Call the "Buy" function in our SDK.
  3. Receive the required data and display the movie.
  4. Call the "GetMoviePlayer" function in our SDK.

 

 

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 "Buy" function in our SDK.

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

<script>	
	function buyMovie(){
		var url = 'https://platform.adultwork.com/Credits/Confirm';
		var returnUri = 'https://example.com?yourreference=abc123456789';	
		var movieId = 12345678912;
		var userId = 123456;
		var clientId = 'A1B2C3D4E5F6';
		
		AW.Buy.init(url, returnUri, 'movie', movieId, userId, 'en-GB', clientId);
		AW.Buy.confirm_window(onClose);
	}		
	
	function onClose(){
		// optional on close callback function.
	}
</script>
  • url
    • The URL of our buy functionality in the platform. This value must be set to 'https://platform.adultwork.com/Credits/Confirm'.
  • returnUri
    • The sdk will open a pop-up. When the user has bought the movie the Unified Login will send the URL of the movie back to this URI.
  • movieId
  • userId
    • The user id of the owner of the movie.
  • 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.

 

 

Receive the required data and display the movie.

Assuming the user has bought the movie you will be able to receive the required data of the movie in the query string and show it to the user. The recommended way to show the movie is to use the AdultWork.con Player.

The Unified Login will return a total of 3 Query String parameters; url, hasencodings and movieid. When you receive the Query String hasencodings that has the value true you have to use the AdultWork.com Player!

Note: The Unified Login always tries to return the encoded version of the movie. Sometimes this is not available and the Unified Login will return an URL which will you can use as a stream or with the player of your choice. You can identify a stream by a trailing slash.
{your-redirect_uri}?url={the-url-of-the-movie}&hasencodings=true&movieid=27569DCC-78E1-4020-9E9C-76366F24062D
  • url
    • The URL of the movie (only populated when hasencodings has a value of false).
  • hasencodings
    • A boolean indicating the movie has encodings and you have to use the AdultWork.com Player.
  • movieid
    • A unique identifier indicating the id of the movie.

 

 

Call the "GetMoviePlayer" function in our SDK.

You received the Query String hasencodings with the value true.
Let's say you have a element with an ID of 'VideoPlayer' in you html page the Unified Login is returning to. You simply call the SDK function AW.GetMoviePlayer.

Note: Make sure the SDK is loaded completely before calling the function.

This function has the following input parameters:

  • MovieID
    • The MovieID returned from the Unified Login.
  • TargetID
    • The ID of the element you which to show the AdultWork.com player in. (VideoPlayer in our example)
  • Width
    • The width of the video. (optional, the default will be 100%)
  • Height
    • The height of the video. (optional, the default will be 100%)
<script>	
	AW.GetMoviePlayer('27569DCC-78E1-4020-9E9C-76366F24062D','VideoPlayer');
</script>

Your video will play in the target