This page will explain how to let a user of your application buy a movie. A couple of steps are required and shown below.
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>
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>
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
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:
<script> AW.GetMoviePlayer('27569DCC-78E1-4020-9E9C-76366F24062D','VideoPlayer'); </script>
Your video will play in the target