{"id":36370479,"url":"https://github.com/dynata/iab-tcf-php","last_synced_at":"2026-01-11T14:00:35.107Z","repository":{"id":42064581,"uuid":"270936258","full_name":"dynata/iab-tcf-php","owner":"dynata","description":"IAB TCF PHP Parsing Library","archived":false,"fork":false,"pushed_at":"2022-08-25T23:36:33.000Z","size":53,"stargazers_count":9,"open_issues_count":5,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-23T10:27:03.628Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dynata.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.log","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-09T07:43:49.000Z","updated_at":"2024-02-24T22:06:14.000Z","dependencies_parsed_at":"2022-08-12T03:50:42.789Z","dependency_job_id":null,"html_url":"https://github.com/dynata/iab-tcf-php","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/dynata/iab-tcf-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynata%2Fiab-tcf-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynata%2Fiab-tcf-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynata%2Fiab-tcf-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynata%2Fiab-tcf-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dynata","download_url":"https://codeload.github.com/dynata/iab-tcf-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynata%2Fiab-tcf-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28306983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T11:18:18.743Z","status":"ssl_error","status_checked_at":"2026-01-11T11:07:56.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-11T14:00:17.203Z","updated_at":"2026-01-11T14:00:35.054Z","avatar_url":"https://github.com/dynata.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Library for Parsing the IAB TC String\n\nThis project includes a PHP Library for working with: \n\n* IAB's [Transparency \u0026 Consent Framework v1.1](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/Consent%20string%20and%20vendor%20list%20formats%20v1.1%20Final.md)\n* IAB's [Transparency \u0026 Consent Framework v2.0](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20Consent%20string%20and%20vendor%20list%20formats%20v2.md)\n\nThe TC String is a technical component of the IAB Europe Transparency \u0026 Consent Framework (TCF).\n\nThe General Data Protection Regulation (GDPR) requires a high level of accountability for how personal data is processed. While important to all parties in the digital advertising ecosystem, implementation of the GDPR came with heavy technical challenges.\n\nThe GDPR requires, amongst others, a legal basis for such processing. The two most relevant legal bases are the consent of the user to the processing of their personal data, and the legitimate interests of the controller or a third party to the processing of a user’s personal data, provided that the interests and fundamental rights of the user are not overriding. Both legal bases require the provision of disclosures to ensure transparency, and the opportunity for user choice either through the user’s consent to the processing of their personal data before the processing starts if the legal basis is consent, or through the user’s objection to the processing of their personal data after the processing starts if the legal basis is a legitimate interest. Under the GDPR, controllers are required to create and maintain records of compliance, including, but not limited to user consent records. This warrants clear standards for a common technical solution for all affected parties and policies to govern how that solution is used.\n\nIAB Europe established the TCF to support compliance with the GDPR in the context of digital advertising.\n\n## Installation\n\nRequire the package via composer\n\n```\ncomposer require dynata/iabtcf\n```\n\n## Usage\n\n### Decode a Consent String\n\n```\n$cs = IABTcf\\Decoder::decode(\"COtybn4PA_zT4KjACBENAPCIAD-AAECAAIAAAxAAAAgAIAwgAgAAAAEAgQAAAAAEAYQAQAAAACAAAABACBQAYAAgAEEgBAABAAQA.IBAgAAAgAIAwgAgAAAAEAAAACA.Qu4QBQAGAAXABLAC8AMAu4A.cAAAAAAAITg\");\n\n// Core String\nvar_dump($cs-\u003egetVersion());\n\nint(2)\n\nvar_dump($cs-\u003egetCreated()-\u003eformat(\"c\"));\n\nstring(25) \"2020-01-26T17:01:00+00:00\"\n\nvar_dump($cs-\u003egetLastUpdated()-\u003eformat(\"c\"));\n\nstring(25) \"2021-02-02T17:01:00+00:00\"\n\nvar_dump($cs-\u003egetCmpId());\n\nint(675)\n\nvar_dump($cs-\u003egetCmpVersion());\n\nint(2)\n\nvar_dump($cs-\u003egetConsentScreen());\n\nint(1)\n\nvar_dump($cs-\u003egetVendorListVersion());\n\nint(15)\n\nvar_dump($cs-\u003egetTcfPolicyVersion());\n\nint(2)\n\nvar_dump($cs-\u003egetConsentLanguage());\n\nstring(2) \"en\"\n\nvar_dump($cs-\u003egetPublisherCC());\n\nstring(2) \"aa\"\n\nvar_dump($cs-\u003egetIsServiceSpecific());\n\nbool(false)\n\nvar_dump($cs-\u003egetPurposeOneTreatment());\n\nbool(true)\n\nvar_dump($cs-\u003egetUseNonStandardStacks());\n\nbool(false)\n\nvar_dump($cs-\u003egetPurposesConsent());\n\narray(7) {\n  [0]=\u003e\n  int(3)\n  [1]=\u003e\n  int(4)\n  [2]=\u003e\n  int(5)\n  [3]=\u003e\n  int(6)\n  [4]=\u003e\n  int(7)\n  [5]=\u003e\n  int(8)\n  [6]=\u003e\n  int(9)\n}\n\nvar_dump($cs-\u003egetVendorConsent());\n\narray(7) {\n  [0]=\u003e\n  int(23)\n  [1]=\u003e\n  int(37)\n  [2]=\u003e\n  int(47)\n  [3]=\u003e\n  int(48)\n  [4]=\u003e\n  int(53)\n  [5]=\u003e\n  int(65)\n  [6]=\u003e\n  int(98)\n}\n\nvar_dump($cs-\u003egetVendorLegitimateInterest());\n\narray(7) {\n  [0]=\u003e\n  int(37)\n  [1]=\u003e\n  int(47)\n  [2]=\u003e\n  int(48)\n  [3]=\u003e\n  int(53)\n  [4]=\u003e\n  int(65)\n  [5]=\u003e\n  int(98)\n  [6]=\u003e\n  int(129)\n}\n\nvar_dump($cs-\u003egetSpecialFeatureOptIns());\n\narray(1) {\n  [0]=\u003e\n  int(1)\n}\n\nvar_dump($cs-\u003egetPurposesLITransparency());\n\narray(2) {\n  [0]=\u003e\n  int(2)\n  [1]=\u003e\n  int(9)\n}\n\n$pubRestrictions = $cs-\u003egetPublisherRestrictions();\nvar_dump($pubRestrictions[0]-\u003egetPurposeId());\n\nint(1)\n\nvar_dump($pubRestrictions[0]-\u003egetRestrictionType()-\u003egetId());\n\nint(1)\n\nvar_dump($pubRestrictions[0]-\u003egetVendorIds());\n\narray(2) {\n  [0]=\u003e\n  int(1)\n  [1]=\u003e\n  int(2)\n}\n\n// Segment 1: Disclosed vendors\nvar_dump($cs-\u003egetDisclosedVendors());\n\narray(8) {\n  [0]=\u003e\n  int(23)\n  [1]=\u003e\n  int(37)\n  [2]=\u003e\n  int(47)\n  [3]=\u003e\n  int(48)\n  [4]=\u003e\n  int(53)\n  [5]=\u003e\n  int(65)\n  [6]=\u003e\n  int(98)\n  [7]=\u003e\n  int(129)\n}\n\n// Segment 2: Allowed vendors\nvar_dump($cs-\u003egetAllowedVendors());\n\narray(6) {\n  [0]=\u003e\n  int(12)\n  [1]=\u003e\n  int(23)\n  [2]=\u003e\n  int(37)\n  [3]=\u003e\n  int(47)\n  [4]=\u003e\n  int(48)\n  [5]=\u003e\n  int(6000)\n}\n\n// Segment 3: Publisher purposes\nvar_dump($cs-\u003egetPubPurposesConsent());\n\narray(1) {\n  [0]=\u003e\n  int(1)\n}\n\nvar_dump($cs-\u003egetPubPurposesLITransparency());\n\narray(1) {\n  [0]=\u003e\n  int(24)\n}\n\nvar_dump($cs-\u003egetCustomPurposesConsent());\n\narray(1) {\n  [0]=\u003e\n  int(2)\n}\n\nvar_dump($cs-\u003egetCustomPurposesLITransparency());\n\narray(2) {\n  [0]=\u003e\n  int(1)\n  [1]=\u003e\n  int(2)\n}\n```\n\n### Encode consent data\n\n```\n$cs = new IABTcf\\ConsentString();\n$cs-\u003esetVersion(2);\n$cs-\u003esetCreated(new DateTime('2020-01-26 17:01:00'));\n$cs-\u003esetLastUpdated(new DateTime('2021-02-02 17:01:00'));\n$cs-\u003esetCmpId(675);\n$cs-\u003esetCmpVersion(2);\n$cs-\u003esetConsentScreen(1);\n$cs-\u003esetVendorListVersion(15);\n$cs-\u003esetTcfPolicyVersion(2);\n$cs-\u003esetConsentLanguage('en');\n$cs-\u003esetPublisherCC('aa');\n$cs-\u003esetIsServiceSpecific(false);\n$cs-\u003esetPurposeOneTreatment(true);\n$cs-\u003esetUseNonStandardStacks(false);\n$cs-\u003esetAllowedPurposes([2, 10]);\n$cs-\u003esetSpecialFeatureOptIns([1]);\n$cs-\u003esetPurposesConsent([3, 4, 5, 6, 7, 8, 9]);\n$cs-\u003esetVendorConsent([23, 37, 47, 48, 53, 65, 98]);\n$cs-\u003esetVendorLegitimateInterest([37, 47, 48, 53, 65, 98, 129]);\n$cs-\u003esetPurposesLITransparency([2, 9]);\n$restrictionType = new IABTcf\\TCFv2\\RestrictionType(1);\n$cs-\u003esetPublisherRestrictions([\n    new IABTcf\\TCFv2\\PublisherRestriction(1, $restrictionType, [1, 2]),\n    new IABTcf\\TCFv2\\PublisherRestriction(2, $restrictionType, [1, 8])\n]);\n\n$cs-\u003esetDisclosedVendors([23, 37, 47, 48, 53, 65, 98, 129]);\n\n$cs-\u003esetAllowedVendors([12, 23, 37, 47, 48, 6000]);\n\n$cs-\u003esetPubPurposesConsent([1]);\n$cs-\u003esetPubPurposesLITransparency([24]);\n$cs-\u003esetCustomPurposesConsent([2]);\n$cs-\u003esetCustomPurposesLITransparency([1, 2]);\n\n// Encode the data into a web-safe base64 string\n$enc = IABTcf\\Encoder::encode($cs);\n\n\necho $enc;\n\nOutputs:\n\nCOtybn4PA_zT4KjACBENAPCIAD-AAECAAIAAAxAAAAgAIAwgAgAAAAEAgQAAAAAEAYQAQAAAACAAAABACBQAYAAgAEEgBAABAAQA.IBAgAAAgAIAwgAgAAAAEAAAACA.Qu4QBQAGAAXABLAC8AMAu4A.cAAAAAAAITg\n```\n\n## Disclaimer\n\nYOU ARE USING THIS APPLICATION AT YOUR OWN RISK. \nDYNATA MAKES NO WARRANTIES OR REPRESENTATIONS ABOUT THIS APPLICATION. \nTHIS APPLICATION IS PROVIDED TO YOU “AS IS”. \nDYNATA HEREBY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED WITH \nRESPECT TO THE APPLICATION, INCLUDING, BUT NOT LIMITED TO, \nTHE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS OF PURPOSE, \nNON-INFRINGEMENT AND ANY IMPLIED WARRANTIES ARISING OUT OF \nA COURSE OF PERFORMANCE, DEALING, OR TRADE USAGE. \nTO THE EXTENT DYNATA MAY NOT, AS A MATTER OF APPLICABLE LAW, \nDISCLAIM ANY WARRANTY, THE SCOPE AND DURATION OF SUCH WARRANTY \nSHALL BE LIMITED TO THE MINIMUM PERMITTED UNDER SUCH APPLICABLE LAW. \nYOU WILL INDEMNIFY, DEFEND AND HOLD HARMLESS DYNATA AND ITS AFFILIATES, \nEMPLOYEES, OFFICERS AND CONTRACTORS FROM ANY THIRD PARTY CLAIM ARISING \nFROM YOUR USE OF THIS APPLICATION.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynata%2Fiab-tcf-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynata%2Fiab-tcf-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynata%2Fiab-tcf-php/lists"}