PHP code example of evalue8bv / creditable-paywall

1. Go to this page and download the library: Download evalue8bv/creditable-paywall library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

evalue8bv / creditable-paywall example snippets


<link rel="stylesheet" type="text/css" href="<?= $creditable->getCssDependency(); 



use Creditable\CreditablePayWall;

$apiKey = 'your-api-key-here';
$options = [
    'environment' => 'dev'
];
$creditable = new CreditablePayWall($apiKey, $options);

// Rest of the code



reditable\CreditablePayWall;

$apiKey = 'your-api-key-here';
$creditable = new CreditablePayWall($apiKey);

$creditable_article_id = "<<ARTICLE ID>>"; // Alphanumeric (C NAME>>"; // Alphanumeric (T_URI']; // Alphanumeric (optional) teaser, used to tease recommended articles to users)
$creditable_article_tags = "<<TAGS>>"; // Alphanumeric (optional) comma delimited list or json (optional keywords, used to find recommended articles for users)
$creditable_article_img = "<<ARTICLE IMG URL>>"; // Alphanumeric (optional) URL for article image

// GET LOCAL CREDITABLE JWT COOKIE
$creditable_cookie = $_COOKIE['cjwt'] ?? "";

// Example usage
$data = [
    'jwt' => $creditable_cookie,
    'article_id' => $creditable_article_id,
    'article_name' => $creditable_article_title,
    'topic_id' => $creditable_topic_id,
    'topic_name' => $creditable_topic_name,
    'topic_desc' => $creditable_topic_desc,
    'topic_url' => $creditable_topic_url,
    'article_url' => $creditable_article_url,
    'article_lang' => $creditable_article_lang,
    'article_authors' => $creditable_article_authors,
    'article_desc' => $creditable_article_desc,
    'article_tags' => $creditable_article_tags,
    'article_img' => $creditable_article_img
];

try {
    $result = $creditable->check($data);
    if ($result->isPaid()) {
        // Access granted
    } else {
        // Access denied
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

<!-- creditable scripts -->
 if (!$result->isPaid()){