I need to make an application in which a card reader will be connected to the system, and I have to read the data of the magnetic card reader if someone changes the card on the supplied card reader.
Since you want to do this in PHP, I assume that this is a web application and that the map is flashed on the client machine where the browser is running.
You may have a keyboard skin emulator (usually you get text such as “123456”), in which case you need to intercept the keyboard / focus and load the data into the form field or AJAX. This can be difficult if the field or browser loses focus and you need to launch the browser in kiosk mode.
Or you can use swiper using other technologies such as serial (RS232 [C]) , which I find is pretty outdated or have a custom interface (which means that usually USB-swiper and a set of APIs). If so, it all depends on which APIs are implemented; some devices come with ActiveX applets that force you to use Internet Explorer technologies on the Windows platform. Some others use Java applets, and you will have to integrate them on a web page.
Finally, some of them have a fully customizable application that can interact with the system in several ways (the case of “custom LIBRARY” is the same, except that you also have to develop your own application!):
- By sending a custom HTTP request to a programmable server. If so, you're in luck; you can program a request for each terminal, for example. "HTTP: // yourserver / gotcard terminal = HOUSE & card = $$ $$ CODE". The user application will be hiding in the background, capture the verification code, send it to the server; and you should poll the server to know when each terminal received the code. You will need to handle false and duplicate codes. Such applications come with several placeholders, such as $$ CODE $$, $$ TIMESTAMP $$, and sometimes $$ SWIPEDIRECTION $$; they are used for staff time-out (swipe the screen from left to right when entering work, from right to left when leaving home).
- By loading code into MySQL or SQL Server, again with programmable placeholders. Here you may be forced to use a VPN / SSH connection to intercept the request, and the provided DB drivers may limit your architectural options.
- By running your own application or script with regular placeholders. In this case, your best options, IMHO, write a script call to
lynx (either Linux or Windows), and dovetail in case # 1, "custom HTTP request."
Unfortunately, various vendors are either prone to the “hacked” side (that is, they provide you with hardware and a minimum of software, an MFC application library and sample, or the source code, and you yourself) or “all-inclusive and non-negotiable” (t .e. you get your reader with a fully configured POS software or application for working with timelogger, and there is no easy way to do anything else with it).
If you use the server side , that is, the PHP script (and not its HTML / text output) and the icon reader are on the same machine, then again it depends on what software you were equipped with something. For servers, keyboard emulation is best (if you have a headless server for no reason to ever connect to the keyboard) or asking for problems (if the magnetic reader and the real keyboard are in competition). RS232 [C] is also very easy to use, on Linux you can ttytail or perhaps even tail -f device in the log file and poll the log file. YOU MAY HAVE PRIVACY QUESTIONS WITH THIS (think "write down all the credit card numbers of all customers in plain text"). Or you can attach the device to PHP using fopen() , no problem.
User API libraries can be complex. You may have to resort to the trick of creating a socket or the name server channel, which opens the device and provides its results for PHP via fsockopen() . Unix sockets and knowledge of programming on a client / server server are required.
UPDATE
In the comment, I saw that you have a library for reading barcodes. I still assume that you are in a web application script (say, three POSs with readers, one server).
A way to do this could be:
// PHP "server" application running as CLI on POS
The web application will periodically request a server; We have two parallel workflows:
- (1) AJAX checks for a swipe
- (2) CLI listens to scroll
- (1) Server is not responding yet
- (2) CLI application sends shortcut
- (1) AJAX checks for a swipe
- (1) Server is not responding yet
- (2) Server checks for wipes
- (1) AJAX checks for a swipe
- (1) The server replies "I received it"
- (2) returns to listening
- (1) the client displays the form and starts processing
- ...