Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (63 sloc) 2.97 KB
* Cleeng API Example 1 - How to protect your content
* you can find tutorial 1 here:
* =====================================================================
* This file should be opened in browser, probably:
* =====================================================================
* Remember, if you want to test payment process, you have to work on sandbox.
* Check how to work with sandbox in Tutorial 3 :
* =====================================================================
// set the ID of the offer you want to sell
$offerId = 'R803743332_PL'; //default offer for
// include PHP SDK
$cleengApi = new Cleeng_Api();
<script type="text/javascript" src=""></script>
<script type="text/javascript">
CleengApi.trackOfferImpression("<?php echo $offerId ?>");
function cleengPurchase() {
CleengApi.purchase("<?php echo $offerId ?>", function (result) {
// reload page after purchase to reveal protected ite
// improve the user experience - learn how to load with AJAX in tutorial 2
<h1>Example 1: Getting started with Cleeng</h1>
<p>In case of any problems, please go back to <a href="">tutorial</a> on Cleeng Open.</p>
<hr />
// Check if visitor has access to protected content
if ($cleengApi->isAccessGranted($offerId)): ?>
Yeah!! You have access to offer <?php echo $offerId ?>. You can define any html here that you want to sell. You have now access to this anywhere, anytime.
<br /><br />
Please note:
<li>A secure token is set, so next time you go to this page (using this browser) you have instant access again. </li>
<li>To access this content from another device, just log in to Cleeng and visit this page. The content is automatically revealed.</li>
<li>To have an overview of all items bought, check your <a href="">Cleeng library</a>. Now this item is listed there as well.</li>
<li>Be aware that as a publisher you have always instant access to the content you published.</li>
<?php else: ?>
Content is not accessible for you. <br /><br />
<input type="button" onClick="javascript:cleengPurchase();" value="Buy access to this content" />
<?php endif; ?>
<hr />
&copy; Safe & secure content protection and monetization by
<a href="" title="Cleeng Content Monetization" target="_blank">
<img src="" alt="Cleeng Content Monetization" title="Cleeng Content Monetization" />