定制 silverback/iubenda-consent-solution 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

silverback/iubenda-consent-solution

Composer 安装命令:

composer require silverback/iubenda-consent-solution

包简介

PHP client for Iubenda Consent Solution HTTP API

README 文档

README

Installation

Install this package in Yii project root with Composer.

composer require silverback/iubenda-consent-solution

Usage

Create a new consent

use Iubenda\ConsentSolution\Client;
use Iubenda\ConsentSolution\Consent;

$consentSolution = new ConsentSolution\Client( 'your-private-api-key' );
$consent = new ConsentSolution\Consent;

$user_id = 10;

$consent->setSubject( 
    [
        'id' => sha1( 'my_application_' . $user_id ), // you can omit this field
        'email' => 'user@example.com',
        'first_name' => 'John',
        'last_name' => 'Doe',
        'full_name' => 'John Doe',
        'verified' => false
    ]
);

$consent->addLegalNotice( [ 'identifier' => 'privacy_policy' ] );            

$consent->addProof( [
    'content' => json_encode( [ 
        'first_name' => 'John', 
        'last_name' => 'Doe', 
        // other useful form fields
    ] ),
    'form' => '<form><input type="text" name="first_name">[...]</form>',
] );

$consent->preferences['privacy_policy'] = true;
$consent->preferences['third_party'] = false;
$consent->preferences['newsletter'] = true;

try {
    $saved_consent = $consentSolution->createConsent( $consent );
    echo "Successfully saved consent: " . $saved_consent->id;
} catch (\Exception $e) {
    echo "An error occurred: " . $e->getMessage();
}

Testing

This class uses PHPUnit as test suite, to test the classes and functions follow this steps.

Copy the file phpunit.xml.dist in phpunit.xml in the library folder and define Api-Key and addresses inside it:

	<php>
        <const name="CONSENT_SOLUTION_API_KEY" value="foobar"/>			
        <const name="CONSENT_SOLUTION_TEST_CONSENT" value="foobar"/>			
        <const name="CONSENT_SOLUTION_TEST_SUBJECT" value="foobar"/>			        
        ...
	</php>

Launch a composer update to install all the dependencies and test suite.

Run the test with the following commands

./vendor/bin/phpunit  tests/  # all tests
./vendor/bin/phpunit  tests/ClientTest # single test

统计信息

  • 总下载量: 481
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-07-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固