我想解码QRCode /条码,我一直在寻找, zxing有一个webservice here,但它不是一个API,所以我不能大量用于我自己的目的。但zxing有一个开源库。 任何人都可以帮助我如何将它与我自己的PHP代码集成?有什么办法吗? 我还发现了php-zbarcode,但它似乎已经停止了。
此致
答案 0 :(得分:1)
答案 1 :(得分:0)
尝试使用它来扫描QR码。它可以在移动设备中选择前置和后置摄像头。设置为带有2个摄像头的设备中的后置摄像头。
https://github.com/schmich/instascan/
<?php
if(isset($_COOKIE['myJavascriptVar']))
{
$phpVar = $_COOKIE['myJavascriptVar'];
enter code here
?>
<html>
<head>
<script type="text/javascript" src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js" ></script>
</head>
<body>
<h3 class="text-center" style="font-family: sans-serif;">Scan the QR Code by Placing the code in front your camera</h3>
<video id="preview"></video>
<script>
let scanner = new Instascan.Scanner(
{
video: document.getElementById('preview')
}
);
scanner.addListener('scan', function(content) {
alert('QR Code Scanned Successfully: ' + content);
document.cookie = "myJavascriptVar = " + content;
var phpID = "<?php echo $actID ?>";
window.location.href = "qrCode?id="+phpID;
});
Instascan.Camera.getCameras().then(cameras =>
{
if(cameras.length = 2){
scanner.start(cameras[1]);
}
if(cameras.length = 1){
scanner.start(cameras[0]);
} else {
console.error("Device does have have available or working camera!");
}
});
</script>
</body>
</html>