php

2013-03-24 2 views
5

में पासबुक के लिए पास बनाएँ I Im मेरे ऐप के लिए गतिशील कूपन बनाने की कोशिश कर रहा है। मेरे पास एक PHP सर्वर है जो उन्हें बनाते हैं। लेकिन मुझे नहीं पता कि वे पासबुक पर क्यों काम नहीं करते हैं।php

यदि मैं टर्मिनल से पास बनाता हूं तो यह ठीक काम करता है। लेकिन पीएचपी-पीकेपास के साथ PHP में।

मैं अपने कंप्यूटर में पास दिखाई देते हैं, लेकिन यह पासबुक में नहीं जोड़ता है (यह भी अगर मैं इसे ई-मेल के माध्यम से भेज) इसके नीचे PHP में कोड छोड़ दिया

इम 100% यकीन है कि passTypeIdentifier, teamIdentifier , प्रमाणपत्र और WWDR 100% कर रहे हैं सही ढंग से

नोट: सभी छवियों मौजूद

<?php 
include ("conexion.php"); 
require('passpk/PKPass.php'); 

if (isset($_GET['cupon']) and $_GET['cupon'] != '' and $_GET['cupon'] > 0) { 

    $cuponID = $_GET['cupon']; 


    $pass = new PKPass\PKPass(); 

    $pass->setCertificate('./Certificate.p12'); // 2. Set the path to your Pass Certificate (.p12 file) 
    $pass->setCertificatePassword('*******');  // 2. Set password for certificate 
    $pass->setWWDRcertPath('./WWDR.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   = array(
     'description'  => 'Store', 
     'formatVersion'  => 1, 
     'organizationName' => 'Store', 
     'passTypeIdentifier' => 'pass.store.store', // 4. Set to yours 
     'serialNumber'  => $cupon['id'], 
     'teamIdentifier'  => '********'   // 4. Set to yours 
    ); 
    $associatedAppKeys = array(); 
    $relevanceKeys  = array(); 
    $styleKeys   = array(
     'coupon' => array(
      'primaryFields' => array(
       array(
        'key' => 'key', 
        'label' => "Label" 
       ) 
      ), 
      'secondaryFields' => array(
       array(
        'key' => 'name', 
        'label' => 'Tienda', 
        'value' => "Name" 
       ), 
       array(
        'key' => 'date', 
        'label' => 'Válido hasta', 
        'value' => "Vigencia" 
       ) 
      ), 
      'backFields' => array(
       array(
        'key' => 'tienda', 
        'label' => 'Tienda', 
        'value' => "tienda" 
       ), 
       array(
        'key' => 'sucursales', 
        'label' => 'Sucursales', 
        'value' => 'Valido en las sucursales y sus horarios' 
       ), 
       array(
        'key' => 'description', 
        'label' => 'Descripción', 
        'value' => "descr" 
       ), 
       array(
        'key' => 'terms', 
        'label' => 'Términos y Condiciones', 
        'value' => "cupon" 
       ) 
      ) 
     ) 
    ); 
    $visualAppearanceKeys = array(
     'barcode'   => array(
      'format'   => 'PKBarcodeFormatPDF417', 
      'message'   => "cupon", 
      'messageEncoding' => 'iso-8859-1' 
     ), 
     'foregroundColor' => 'rgb(255, 255, 255)', 
     'backgroundColor' => 'rgb(4, 148, 203)', 
     'logoText'  => 'cupon' 
    ); 
    $webServiceKeys  = array(); 

    // Merge all pass data and set JSON for $pass object 
    $passData = array_merge(
     $standardKeys, 
     $associatedAppKeys, 
     $relevanceKeys, 
     $styleKeys, 
     $visualAppearanceKeys, 
     $webServiceKeys 
    ); 

    $pass->setJSON(json_encode($passData)); 

    //creating a temp file called strip.png 
    //generamos un directorio temporal y creamos el strip 
    $uniqID = uniqid('', true); 
    $dir = './tempDir/'.$uniqID; 
    mkdir($dir, 0777); 

    //copiamos el archvio al nuevo directorio 
    copy('../'.$img, './tempDir/'.$uniqID.'/strip.png'); 

    // Add files to the PKPass package 
    $pass->addFile($dir.'/strip.png'); 
    $pass->addFile('images/icon.png'); 
    $pass->addFile('images/[email protected]'); 
    $pass->addFile('images/logo.png'); 
    $pass->addFile('images/[email protected]'); 

    if(!$pass->create(true)) { // Create and output the PKPass 
     echo 'Error: '.$pass->getError(); 
    } 

    //borramos el folder temp 
    unlink($dir.'/strip.png'); 
    rmdir($dir); 
} 
+0

आप अपने डिवाइस पर अपने गुजरता है, क्या आप कंसोल में देख पा रहे हैं में से एक इंस्टॉल करते हैं (यह देखने के लिए, अपने iPhone को एक मैक करने के लिए, हुक Xcode का शुभारंभ और विंडो क्लिक करें -> आयोजक)। – PassKit

+0

आईफोन में मैं इसे इंस्टॉल नहीं कर सकता क्योंकि यह cupon.pkpass – Edig

+0

जैसा दिखता है यह हो सकता है कि सफारी फ़ाइल डाउनलोड कर रहा है क्योंकि यह इसे पास फ़ाइल के रूप में नहीं पहचानता है - क्या आप इसे 'सामग्री-प्रकार: एप्लिकेशन' के साथ सेवा दे रहे हैं/vnd.apple.pkpass' हेडर? – PassKit

उत्तर

3

सांत्वना उत्पादन को देखते हुए के रूप में मैं अपने पास स्थापित करने के लिए प्रयास किया, मैं निम्नलिखित चेतावनी दिखाई।

Mar 25 10:45:40 iPhone MobileSafari[279] <Warning>: Invalid data error reading pass pass.cuponice.cuponice/9. Pass dictionary must contain key 'value'. 
Mar 25 10:45:40 iPhone MobileSafari[279] <Warning>: PassBook Pass download failed: The pass cannot be read because it isn't valid. 

अपने pass.json में खुदाई, मुझे लगता है कि अपने primaryFields शब्दकोश एक 'मान' कुंजी शामिल नहीं है।

"primaryFields": [{ 
      "key": "key", 
      "label": "30% de Descuento en Persianas" 
     } 
    ], 

ठीक करने के लिए, अपने primaryFields शब्दकोश में एक value कुंजी जोड़ने के लिए अपने PHP बदल जाते हैं।

$styleKeys = array(
    'coupon' => array(
     'primaryFields' => array(
      array(
       'key' => 'key', 
       'label' => "Label", 
       'value' => "" 
      ) 
     ),       //... 
+0

काम करता है धन्यवाद पुरुष यह पूरी तरह से काम करता है मैं "मूल्य" को समाप्त करता हूं क्योंकि मैं इसे प्रकट नहीं करना चाहता था। लेकिन धन्यवाद! – Edig

संबंधित मुद्दे

 संबंधित मुद्दे