getAccessStatus

Returns for a user the entitlement of a specific offer. It answers the question if you should load and display the premium content for a given subscriber.

For security reasons, this validation needs to happen server-side. The response of this method (true or false) defines if you can show the premium content. Mostly it defines the page or application to return via two different versions:

  • Users who cannot see the content as a visitor is new on your website or the subscription expired (getAccessStatus returns false)
  • Users who can see the content as a visitor has an active subscription (getAccessStatus returns true)

There are two ways of using this method. The first is checking access to one, particular offer for some country like for the US (look at the request example).

The second way is to check if the user has access to the offer in any country. To do so, just skip the country tag suffix. For example:

Offer ID WITH the country suffix:

S580476507_US

The same offer ID WITHOUT country suffix:

S580476507

Entitlement checks are used as a base for reporting. You can see the recommended approach to using the entitlement methods here.

📘

You can try that method by clicking here

Parameters

Name

Type

Description

customerToken*

string

Token that identifies the customer, read more in Must know about API section

offerId*

string

ID of the offer for which access is checked

ipAddress

string

In order to prevent using the offer from too many devices, there's a limit of 4 IP addresses per user. A single address is marked by used for 3 hours. That means, that if the user used too many devices and an IP address was blacklisted, after 3 hours it will be available again if some other IP address expires

Result Parameters

Name

Type

Description

accessGranted

boolean

Information about user's access to given offer

grantType

string

Information about method granting access for customer

expiresAt

integer

Expiration date for access to given offer. This value is approximate, parameter accessGranted contains valid information about user's access

purchasedDirectly

boolean

deprecated

API Request/Response

Request

{    
   "method": "getAccessStatus",    
     "params": {    
       "customerToken": "GeO3HV8Zmf4o4ID6QPBwRDghN9MXGiOLekgmXlKW-yJWpN-j",   
       "offerId": "S580476507_US",   
       "ipAddress": "192.0.2.10"    
     },    
     "jsonrpc": "2.0",    
     "id": 1    
 }

Response

{    
  "result": {    
    "accessGranted": true,    
    "grantType": "direct-purchase",    
    "expiresAt": null,    
    "purchasedDirectly": true
  },    
  "id": "1",    
  "error": null,    
  "jsonrpc": "2.0"    
}

PHP Example

<?php
    $offerId = 'S580476507_PL';

    $cleengApi =  new Cleeng_Api();

    $offerAccess = $cleengApi->getAccessStatus($offerId);

    if($offerAccess->accessGranted) {
    //user has access to the content. Put your content here,
    } else {
    //user has no access, show 'Buy' button. Read more in Tutorial 1 - Protect you content
    }
?>

ErrorCodes

Code

Description

1

Invalid customer token

4

Offer not found

14

IP address limit exceed

16

Invalid arguments