"value": "' . $passenger . '" } ], "transitType" : "PKTransitTypeAir" }, "barcode": { "format": "PKBarcodeFormatQR", "message": "Flight-Gate' . $gate . '-' . $date . '-' . $passenger . '-' . $destination . '", "messageEncoding": "iso-8859-1" } }'); if ($pass->checkError($error) == true) { exit('An error occured: ' . $error); } // add files to the PKPass package $pass->addFile('../images/icon.png'); $pass->addFile('../images/icon@2x.png'); $pass->addFile('../images/logo.png'); // specify english and french localizations $pass->addFile('en.strings', 'en.lproj/pass.strings'); $pass->addFile('fr.strings', 'fr.lproj/pass.strings'); if ($pass->checkError($error) == true) { exit('An error occured: ' . $error); } //If you pass true, the class will output the zip into the browser. $result = $pass->create(true); if ($result == false) { // Create and output the PKPass echo $pass->getError(); } } else {
"key": "id", "label": "Card Number", "value": "' . $id . '" } ] }, "barcode": { "format": "PKBarcodeFormatPDF417", "message": "' . $id . '", "messageEncoding": "iso-8859-1", "altText": "' . $id . '" } }'); // add files to the PKPass package $pass->addFile('icon.png'); $pass->addFile('*****@*****.**'); $pass->addFile('logo.png'); $pass->addFile('background.png', 'strip.png'); if ( !$pass->create(true)) { // Create and output the PKPass echo 'Error: ' . $pass->getError(); } exit; } else { // User lands here, there are no $_POST variables set ?><html> <head> <title>Starbucks pass creator - PHP class demo</title>
<?php use PKPass\PKPass; require '../PKPass.php'; $pass = new PKPass(); $pass->setCertificate('../Certificate.p12'); // 1. Set the path to your Pass Certificate (.p12 file) $pass->setCertificatePassword('test123'); // 2. Set password for certificate $pass->setWWDRcertPath('../AppleWWDRCA.pem'); // 3. Set the path to your WWDR Intermediate certificate (.pem file) // Top-Level Keys http://developer.apple.com/library/ios/#documentation/userexperience/Reference/PassKit_Bundle/Chapters/TopLevel.html $standardKeys = ['description' => 'Demo pass', 'formatVersion' => 1, 'organizationName' => 'Flight Express', 'passTypeIdentifier' => 'pass.com.apple.test', 'serialNumber' => '123456', 'teamIdentifier' => 'AGK5BZEN3E']; $associatedAppKeys = []; $relevanceKeys = []; $styleKeys = ['boardingPass' => ['primaryFields' => [['key' => 'origin', 'label' => 'San Francisco', 'value' => 'SFO'], ['key' => 'destination', 'label' => 'London', 'value' => 'LHR']], 'secondaryFields' => [['key' => 'gate', 'label' => 'Gate', 'value' => 'F12'], ['key' => 'date', 'label' => 'Departure date', 'value' => '07/11/2012 10:22']], 'backFields' => [['key' => 'passenger-name', 'label' => 'Passenger', 'value' => 'John Appleseed']], 'transitType' => 'PKTransitTypeAir']]; $visualAppearanceKeys = ['barcode' => ['format' => 'PKBarcodeFormatQR', 'message' => 'Flight-GateF12-ID6643679AH7B', 'messageEncoding' => 'iso-8859-1'], 'backgroundColor' => 'rgb(107,156,196)', 'logoText' => 'Flight info']; $webServiceKeys = []; // Merge all pass data and set JSON for $pass object $passData = array_merge($standardKeys, $associatedAppKeys, $relevanceKeys, $styleKeys, $visualAppearanceKeys, $webServiceKeys); $pass->setJSON(json_encode($passData)); // Add files to the PKPass package $pass->addFile('images/icon.png'); $pass->addFile('images/icon@2x.png'); $pass->addFile('images/logo.png'); if (!$pass->create(true)) { // Create and output the PKPass echo 'Error: ' . $pass->getError(); }