nicolasbringas/iab-consent
最新稳定版本:1.0.0
Composer 安装命令:
composer require nicolasbringas/iab-consent
包简介
PHP IAB Consent String Parsing Library
README 文档
README
Please refer to this project for an updated version supporting both v1.1 and v2.
https://github.com/dynata/iab-tcf-php
PHP Support for GDPR
This project includes a PHP Library for working with the IAB's GDPR Transparency & Consent Framework.
Installation with composer
composer require nicolasbringas/iab-consent
Usage
Decode a Consent String
$cs = new IABConsent\ConsentString("BOQ6ZEAOQ6ZEAABACDENAOwAAAAHCADAACAAQAAQ");
echo "Created Timestamp: " . $cs->getCreated()->getTimestamp() . "\n";
echo "Updated Timestamp: " . $cs->getLastUpdated()->getTimestamp() . "\n";
echo "Version: " . $cs->getVersion() . "\n";
echo "CMP Id: " . $cs->getCmpId() . "\n";
echo "CMP Version: " . $cs->getCmpVersion() . "\n";
echo "Consent Screen: " . $cs->getConsentScreen() . "\n";
echo "Consent Language: " . $cs->getConsentLanguage() . "\n";
echo "Vendor List Version: " . $cs->getVendorListVersion() . "\n";
echo "Allowed Purposes: " . implode(", ", $cs->getPurposesAllowed()) . "\n";
echo "Allowed Vendors: " . implode(", ", $cs->getVendorsAllowed()) . "\n";
echo "Purpose 1 is " . (($cs->isPurposeAllowed(1)) ? "Allowed" : "Not Allowed") . "\n";
echo "Purpose 3 is " . (($cs->isPurposeAllowed(3)) ? "Allowed" : "Not Allowed") . "\n";
echo "Vendor 1 is " . (($cs->isPurposeAllowed(1)) ? "Allowed" : "Not Allowed") . "\n";
echo "Vendor 3 is " . (($cs->isPurposeAllowed(3)) ? "Allowed" : "Not Allowed") . "\n";
Outputs
Created Timestamp: 1531612800
Updated Timestamp: 1531612800
Version: 1
CMP Id: 1
CMP Version: 2
Consent Screen: 3
Consent Language: en
Vendor List Version: 14
Allowed Purposes: 1, 2
Allowed Vendors: 1, 2, 4
Purpose 1 is Allowed
Purpose 3 is Not Allowed
Vendor 1 is Allowed
Vendor 3 is Not Allowed
Encode consent data
$cs = new IABConsent\ConsentString();
// Set the global vendor list
// You need to download and provide the vendor list yourself
// It can be found here - https://vendorlist.consensu.org/vendorlist.json
$cs->setGlobalVendorList($vendorList);
// Set the consent data
$cs->setCmpId(1);
$cs->setCmpVersion(1);
$cs->setConsentScreen(1);
$cs->setConsentLanguage('en');
$cs->setPurposesAllowed([1,2,4]);
$cs->setVendorsAllowed([1,24,245]);
// Encode the data into a web-safe base64 string
echo "Consent String: " . $cs->getConsentString() . "\n";
统计信息
- 总下载量: 4.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-04