1. Go to this page and download the library: Download anura/anura-sdk-php 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/ */
anura / anura-sdk-php example snippets
// Require the Composer autoloader.
quire/include that.
its autoloader.
Request;
use Anura\AdditionalData;
use Anura\DirectResult;
use Anura\Excepion\AnuraException;
use Anura\Exception\AnuraClientException;
use Anura\Exception\AnuraServerException;
// Instantiate an Anura Direct client.
$direct = new AnuraDirect('your-instance-id-goes-here');
/**
* To send additional data to Anura Direct, use the AdditionalData class.
* We will provide this object when calling $direct->getResult()
*/
$additionalData = new AdditionalData();
$additionalData->addElement(1, 'your-data-value');
/**
* To update an element of additional data,
* simply add the element again but with a new value
*/
$indexToUpdate = 1;
$additionalData->addElement($indexToUpdate, 'your-new-data-value');
try {
$result = $direct->getResult($request);
} catch (AnuraClientException $e) {
// Handle 4XX responses here.
} catch (AnuraServerException $e) {
// Handle 5XX responses here.
} catch (AnuraException $e) {
/**
* Handle any other exceptions that may have occurred.
* Since AnuraClientException & AnuraServerException are children of AnuraException,
* feel free to remove those handling blocks if your handling logic is the same for both.
*/
}
// We got a result (a DirectResult object)!
// See below for available properties & DirectResult objects.
// $result->isSuspect();
// $result->isNonSuspect();
// $result->isMobile();
// $anuraResult = $result->result;
// $visitorWasMobile = $result->mobile;
// $ruleSets = $result->ruleSets;
// $invalidTrafficType = $result->invalidTrafficType;
echo "result: $result";
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.