PHP code example of mediapart / lapresselibre-bundle

1. Go to this page and download the library: Download mediapart/lapresselibre-bundle 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/ */

    

mediapart / lapresselibre-bundle example snippets


# app/AppKernel.php

$bundles = array(
    // ...
    new Mediapart\Bundle\LaPresseLibreBundle\MediapartLaPresseLibreBundle(),
);


# src/Acme/LaPresseLibre/Verification.php

namespace AppBundle\LaPresseLibre;

use Mediapart\LaPresseLibre\Subscription\Type as SubscriptionType;

class Verification
{
    private $public_key;

    public function __construct($public_key)
    {
        $this->public_key = $public_key;
    }

    public function alwaysVerifiedAccounts(array $data, $isTesting = false)
    {
        $now = new \DateTime('next year');
        return [
            'Mail' => $data['Mail'],
            'CodeUtilisateur' => $data['CodeUtilisateur'],
            'TypeAbonnement' => SubscriptionType::MONTHLY,
            'DateExpiration' => $now->format("Y-m-d\TH:i:sO"),
            'DateSouscription' => $now->format("Y-m-d\TH:i:sO"),
            'AccountExist' => true,
            'PartenaireID' => $this->public_key,
        ];
    }
}