Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2013
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Working with Passkit API

    I am trying to get the passkit API to work in a function from my functions folder. I have tested it in its own file and it works now I am updating with variables and implementing in a email function and it is not working anymore.

    Sample code that works
    PHP Code:
    <?php
    include_once("class-PassKit-v2.php");

    $apiKey "1zqw5NmkQMzjzC9GP5Brx";
    $apiSecret "QnRSphRTzGdF6JMsno4n5eIRLWnNFJ7Vi0wlOS/YIs/yyLvVgk9Nm";
    $templateName "Test";
    // Create new PassKit object
    $pk = new PassKit($apiKey$apiSecret);
     
    // Set data
    $data["barcodeContent"] = "https://www.qrpunchcard.com/api/customer/admin/checkin.php?id=42";
     
    $result $pk->issuePass($templateName$data);
     
    // Do something with result
    print_r($result);
    ?>
    Function where it fails
    PHP Code:
    function register_user($register_data) {
        
    array_walk($register_data'array_sanitize');
        
    $register_data['password'] = md5($register_data['password']);

        
    $fields '`' implode('`, `'array_keys($register_data)) . '`';
        
    $data '\'' implode('\', \'',  $register_data) . '\'';

        
        
    mysql_query("INSERT INTO `customers` ($fields) VALUES ($data)");
        
    $qr_image '<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=http://www.qrpunchcard.com/api/customer/admin/checkin.php?id=' mysql_insert_id() . '&choe=UTF-8" title="Your QR Code" />';
        
    $username_reg_user $register_data['username'];
        
    mysql_query("UPDATE `customers` SET `qr_img` = '$qr_image' WHERE `username` = '$username_reg_user'");


        
        
    $apiKey "1zqw5NmkQMzjzC9GP5Brx";
        
    $apiSecret "QnRSphRTzGdF6JMsno4n5eIRLWnNFJ7Vi0wlOS/YIs/yyLvVgk9Nm";
        
    $templateName "Test";
        
    // Create new PassKit object
        
    $pk = new PassKit($apiKey$apiSecret);
         
        
    // Set data
        
    $data["barcodeContent"] = "" $qr_image "";
         
        
    $result $pk->issuePass($templateName$data);

    $HTML="
    <style>
    <!--
    .form_tbl{ border:1px solid #bbbbbb; background-color:#eeeeee;}
    .form_tbl td{
        font-size:12px;
        color:#555555;
        padding:5px 5px;
    }
    h3{ 
        font-family:Georgia, Times New Roman, Times, serif;
        font-size:12px;
        font-weight:bold;
        color:#0099CC;
        margin:0;
        padding:0;
    }
    .form_tbl td select{ margin:0; padding:0;}
    .tbl_brdr{ border-top:1px solid #bbbbbb; border-left:1px solid #bbbbbb;}
    .tbl_brdr td{ border-bottom:1px solid #bbbbbb;  border-right:1px solid #bbbbbb; padding:5px 5px 5px 10px; }
    -->
    </style>

    <table class='form_tbl' width='650' border='0' cellspacing='0' cellpadding='3'>

        <tr>
          <td colspan='2'><strong></strong></td>
        </tr>
        <tr>
          <td width='250' >Hello " 
    $register_data['fname'] . ",</td>
          <td ></td>
        </tr>
        <tr>
          <td  valign='middle'>
        You need to activate your account, please use the link below: <br /><br />

        <a href=\"http://qrpunchcard.com/api/customer/admin/activate.php?email=" 
    $register_data['email'] . "&email_code=" $register_data['email_code'] . "\">Activate My Account</a><br /><br />

        Here is your QR Code: <br /><br />

        " 
    $qr_image " <br />" $result "<br />

        <a href=\"" 
    $result['url'] . "\"><img src=\"https://devimages.apple.com.edgekey.net/news/images/feed-images/news-passbook.png\" /></a><br /><br />

        - QR PunchCard Admin

          </td>
          <td  valign='top'></td>
        </tr>
      </table>
    "
    ;

    $from'andrew@websbydrew.com';
    $subject='Please register your account.';
    $to$register_data['email'];
    //$to='development@ezone.com.np';
    function sendHTMLemail($HTML,$from,$to,$subject)
    {
    // First we have to build our email headers
    // Set out "from" address

        
    $headers "From: $from\r\n"

    // Now we specify our MIME version

        
    $headers .= "MIME-Version: 1.0\r\n"

    // Now we attach the HTML version

        
    $headers .= //"--$boundary\r\n".
                    
    "Content-Type: text/html; charset=ISO-8859-1\r\n";
                    
    //"Content-Transfer-Encoding: base64\r\n\r\n"; 
    // And then send the email ....

        
    if (mail($to,$subject,$HTML,$headers)) 
    {

      
    $_SESSION['msg']="Details successfully sent!";


    else 
    {
      
    $_SESSION['msg']="Sending Failed! Please try again later.";

    }
    }
    sendHTMLemail($HTML,$from,$to,$subject);


    require 'class-PassKit-v2.php'; is at the start of the users.php document where the function is.

    Thank you,

  • #2
    New Coder
    Join Date
    Jan 2013
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This has been resolved.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •