diff options
author | Rob Janssen <rob@devcorner.nl> | 2017-01-03 10:42:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-03 10:42:48 +0100 |
commit | b3bb9685eaa8317c15715d35f0f86b251c2dc756 (patch) | |
tree | 4d155474e8108ea8957bfecf6224c6541612a132 | |
parent | 0b5d455b277386899b1499fbe0cf198fd3a727b7 (diff) | |
parent | d03e976891e5a59bca98e0f09ce663386c40c5f3 (diff) | |
download | TwoFactorAuth-b3bb9685eaa8317c15715d35f0f86b251c2dc756.zip TwoFactorAuth-b3bb9685eaa8317c15715d35f0f86b251c2dc756.tar.gz TwoFactorAuth-b3bb9685eaa8317c15715d35f0f86b251c2dc756.tar.bz2 |
Merge pull request #14 from martijncalker/fix-example-readme
Fix php examples in readme
-rw-r--r-- | README.md | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -58,7 +58,7 @@ The `createSecret()` method accepts two arguments: `$bits` (default: `80`) and ` ````php // Display shared secret -<p>Please enter the following code in your app: '<?php echo $secret ?>'</p> +<p>Please enter the following code in your app: '<?php echo $secret; ?>'</p> ```` Another, more user-friendly, way to get the shared secret into the app is to generate a [QR-code](http://en.wikipedia.org/wiki/QR_code) which can be scanned by the app. To generate these QR codes you can use any one of the built-in `QRProvider` classes: @@ -74,7 +74,7 @@ The built-in providers all have some provider-specific 'tweaks' you can 'apply'. ````php // Display QR code to user <p>Scan the following image with your app:</p> -<p><img src="<?php $tfa->getQRCodeImageAsDataUri('Bob Ross', $secret) ?>"></p> +<p><img src="<?php echo $tfa->getQRCodeImageAsDataUri('Bob Ross', $secret); ?>"></p> ```` When outputting a QR-code you can choose a `$label` for the user (which, when entering a shared secret manually, will have to be chosen by the user). This label may be an empty string or `null`. Also a `$size` may be specified (in pixels, width == height) for which we use a default value of `200`. @@ -101,10 +101,17 @@ Simple as 1-2-3. All we need is 3 methods and a constructor: ````php -__construct($issuer=null, $digits=6, $period=30, $algorithm='sha1', $qrcodeprovider=null, $rngprovider=null) -createSecret($bits = 80, $requirecryptosecure = true) -getQRCodeImageAsDataUri($label, $secret, $size = 200) -verifyCode($secret, $code, $discrepancy = 1, $time = null) +public function __construct( + $issuer = null, + $digits = 6, + $period = 30, + $algorithm = 'sha1', + RobThree\Auth\Providers\Qr\IQRCodeProvider $qrcodeprovider = null, + RobThree\Auth\Providers\Rng\IRNGProvider $rngprovider = null +); +public function createSecret($bits = 80, $requirecryptosecure = true): string; +public function getQRCodeImageAsDataUri($label, $secret, $size = 200): string; +public function verifyCode($secret, $code, $discrepancy = 1, $time = null): bool; ```` ### QR-code providers @@ -132,7 +139,7 @@ Let's see if we can use [PHP QR Code](http://phpqrcode.sourceforge.net/) to impl <?php require_once '../../phpqrcode.php'; // Yeah, we're gonna need that -namespace RobThree\Auth\Providers\Qr +namespace RobThree\Auth\Providers\Qr; class MyProvider implements IQRCodeProvider { public function getMimeType() { @@ -159,7 +166,7 @@ $mp = new RobThree\Auth\Providers\Qr\MyProvider(); $tfa = new RobThree\Auth\TwoFactorAuth('My Company', 6, 30, 'sha1', $mp); $secret = $tfa->createSecret(); ?> -<p><img src="<?php $tfa->getQRCodeImageAsDataUri('Bob Ross', $secret) ?>"></p> +<p><img src="<?php echo $tfa->getQRCodeImageAsDataUri('Bob Ross', $secret); ?>"></p> ```` VoilĂ . Couldn't make it any simpler. |