Quellcode durchsuchen

:sparkles: separate authenticator example

smiley vor 8 Jahren
Ursprung
Commit
693e1ee965
2 geänderte Dateien mit 31 neuen und 8 gelöschten Zeilen
  1. 27 0
      examples/authenticator.php
  2. 4 8
      examples/example.php

+ 27 - 0
examples/authenticator.php

@@ -0,0 +1,27 @@
+<?php
+/**
+ *
+ * @filesource   authenticator.php
+ * @created      10.11.2017
+ * @author       Smiley <smiley@chillerlan.net>
+ * @copyright    2017 Smiley
+ * @license      MIT
+ */
+
+require_once '../vendor/autoload.php';
+
+use chillerlan\{
+	GoogleAuth\Authenticator,
+	QRCode\QRCode,
+	QRCode\Output\QRMarkup
+};
+
+$authenticator = new Authenticator;
+
+$secret = $authenticator->createSecret(); // -> userdata
+$data   = $authenticator->getUri($secret, 'label', 'example.com');
+
+// markup - svg
+echo '<!DOCTYPE html><html><head><meta charset="UTF-8"/></head><body><div>'.(new QRCode($data, new QRMarkup))->output().'</div></body>';
+
+

+ 4 - 8
examples/example.php

@@ -9,16 +9,12 @@
 
 
 require_once '../vendor/autoload.php';
 require_once '../vendor/autoload.php';
 
 
-use chillerlan\GoogleAuth\Authenticator;
-use chillerlan\QRCode\Output\{QRMarkup, QRMarkupOptions, QRImage, QRString,QRStringOptions};
+use chillerlan\QRCode\Output\{
+	QRMarkup, QRMarkupOptions, QRImage, QRString, QRStringOptions
+};
 use chillerlan\QRCode\QRCode;
 use chillerlan\QRCode\QRCode;
 
 
-#$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
-#$data = 'skype://echo123';
-$authenticator = new Authenticator;
-
-# otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net
-$data   = $authenticator->getUri($authenticator->createSecret(), 'test', 'chillerlan.net');
+$data = 'https://www.youtube.com/watch?v=DLzxrzFCyOs&t=43s';
 
 
 ?>
 ?>
 <!DOCTYPE html>
 <!DOCTYPE html>