PHP code example of rob006 / yii2-simple-auth-yii-authenticator

1. Go to this page and download the library: Download rob006/yii2-simple-auth-yii-authenticator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rob006 / yii2-simple-auth-yii-authenticator example snippets


use yii\httpclient\Client;
use rob006\simpleauth\YiiAuthenticator as Authenticator;

$client = new Client();
$request = $client->createRequest()
	->setUrl('http://api.example.com/user/list/')
	->setData(['ids' => '1,2,3,4']);
$request = Authenticator::authenticate($request);
$response = $request->send();

use yii\httpclient\Client;
use rob006\simpleauth\YiiAuthenticator as Authenticator;

$client = new Client();
$request = $client->createRequest()
	->setUrl('http://api.example.com/user/list/')
	->setData(['ids' => '1,2,3,4']);
$request = Authenticator::authenticate($request, Authenticator::METHOD_GET, 'mycustomsecretkey');
$response = $request->send();

use yii\httpclient\Client;
use rob006\simpleauth\YiiAuthenticator as Authenticator;

$client = new Client();
$request = $client->createRequest()
	->setUrl('http://api.example.com/user/list/?ids=1,2,3,4');
$request = Authenticator::authenticate($request, Authenticator::METHOD_POST);
$response = $request->send();