tschoffelen / php-pkpass

💳 PHP class for creating passes for Wallet on iOS.
https://includable.com
MIT License
908 stars 187 forks source link

Pass Variables via URL string #92

Closed joshobrienau closed 5 years ago

joshobrienau commented 5 years ago

Currently variable URL strings are ignored with PKPass, has anyone resolved this? So that URL variables can be passed to make generation of passes easy for end users.

For example: www.example.com/pass/?name=John&barcode=12345

Which can then fill the required fields to generate dynamic passes automatically.

tschoffelen commented 5 years ago

Hi there, have a look at this example to see how to use GET or POST parameters to make your pass dynamic: https://github.com/tschoffelen/php-pkpass/blob/master/examples/starbucks_sample/index.php#L29

This example uses $_POST, but it is of course easy enough to replace that by $_GET to access the URL parameters.

joshobrienau commented 5 years ago

Cool thanks for that, that sort of covers part of what I'm wanting to do.

However I was more wanting the URL parameters to pre-fill the text input fields, so say a user wanted to edit their pass to update their name for example. So sending the data in the URL would pre-fill the text fields, but still allow them to edit any of the pre-filled fields before creating the pass?

Also one other thing I've not been able to solve for, is using hyperlinks for the backfields on the back of the pass. Whenever I add hyperlinks the PHP won't load, it just crashes.

I'm wanting to add the hyperlink as an option on the back of the pass as "Update Pass" option, which takes them to the above mentioned dynamic URL with the variable parameters.

tschoffelen commented 5 years ago

Both of these things seem more like general PHP questions than anything related to this library, so it might be better to just do some googling or search on Stack Overflow.

joshobrienau commented 5 years ago

Yeah was more so if someone had already resolved these issues and was planning a pull, especially around hyperlinks in the PHP code, which are outlined in Apple's pass developer documenation, if any of these have spaces or special characters being passed through variables, the PHP crashes.

I've made the changes to the PHP code to allow both variables to auto generate and populate text fields, so I'll close off this issue.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.