PHP code example of w4s / w4s-php

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

    

w4s / w4s-php example snippets




use Wallet4SalesPHP\Wallet4Sales;

$data['BackgroundColor'] = "rgb(255,255,255)";
$data['ForegroundColor'] = "rgb(0, 0, 0)";
$data['LabelColor'] = "rgb(0, 0, 0)";
$data['OrganizationName'] = "Test";
$data['PassTypeIdentifier'] = "Change this";
$data['TeamIdentifier'] = "Change this";
$data['PassType'] = {PASS_TYPE_ID};
$data['CertificateID'] = {CERTIFICATE_ID};
$data['TemplateName'] = "{TEMPLATE_NAME}";
$data['Description'] = "A little description";
$data['Content'] = array(
  "Items" => array(
    "bodyHeader" => array(
      array(
        "label" => "String",
        "value" => "String",
        "LabelIsDinamic" => bool,
        "ValueIsDinamic" => bool,
        "ChangeMessage" => "string",
        "TextAlign" => "string"
      )
    )
  )
);

$data['Images']['strip'] = "IconCode or Url";

$API_KEY = '{Your API_KEY}';

$w4s = new Wallet4Sales();
$w4s->setAccesToken($API_KEY);
$Template = $w4s->CreateTemplate($data);
print_r($Template);




use Wallet4SalesPHP\Wallet4Sales;

$w4s = new Wallet4Sales();
$w4s->setAccesToken($API_KEY);

$CSR = $w4s->CreateCSR();
print_r($CSR);



use Wallet4SalesPHP\Wallet4Sales;

$cer = 'Certificates/pass.cer';
$json = array(
  "certificate" => base64_encode(file_get_contents($cer))
);

$w4s = new Wallet4Sales();
$w4s->setAccesToken($API_KEY);

$Certificate = json_decode($w4s->LoadCertificate($json),true);
print_r($Certificate);



use Wallet4SalesPHP\Wallet4Sales;

$w4s = new Wallet4Sales();
$w4s->setAccesToken($API_KEY);

$data['Name'] = '{CAMPAIGN_NAME}';
$data['TemplateCode'] = '{TEMPLATE_CODE}';
$data['Description'] = '{DESCRIPTION}';

$Campaign = $w4s->CreateCampaign($data);
print_r($Campaign);



use Wallet4SalesPHP\Wallet4Sales;

$w4s = new Wallet4Sales();
$w4s->setAccesToken($API_KEY);

$Pass = $w4s->CreatePass('{CAMPAIGN_CODE}');
print_r($Pass);