getAccessStatus()


Returns information about logged in user access to offer.

There are two ways of using this method. The first is checking access to one, particular offer for some country like for 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

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 addres was blacklisted, after 3 hours it will be available again if some other IP address expires

- required parameter

Response 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

Error Codes:

Code Description
1 Invalid customer token
4 Offer not found
14 IP address limit exceed
16 Invalid arguments

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"
}

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
    }
    
?>

Remember! you can always check it by yourself using API Console - getAccessStatus()

Back to Customer API