dev-master
9999999-dev https://github.com/SummerWQM/sift-phpSift Science PHP library
MIT
The Requires
- php >=5.0.0
The Development Requires
by Yoav Schatzberg
by Alex Lopatin
by Jacob Burnim
php fraud sift science sift
Wallogit.com
2017 © Pedro Peláez
Sift Science PHP library
Add siftscience/sift-php as a dependency in composer.json., (*1)
"require": {
...
"siftscience/sift-php" : "2.*"
...
}
Run composer update., (*2)
Now SiftClient will be autoloaded into your project., (*3)
require 'vendor/autoload.php';
$sift = new SiftClient(array(
'api_key' => 'my_api_key',
'account_id' => 'my_account_id'
));
// or
Sift::setApiKey('my_api_key');
Sift::setAccountId('my_account_id');
$sift = new SiftClient();
Download the latest release., (*4)
Extract into a folder in your project root named "sift-php"., (*5)
Include SiftClient in your project like this:, (*6)
require 'sift-php/lib/Services_JSON-1.0.3/JSON.php';
require 'sift-php/lib/SiftRequest.php';
require 'sift-php/lib/SiftResponse.php';
require 'sift-php/lib/SiftClient.php';
require 'sift-php/lib/Sift.php';
$sift = new SiftClient(array(
'api_key' => 'my_api_key',
'account_id' => 'my_account_id'
));
Here's an example that sends a $transaction event to sift., (*7)
$sift = new SiftClient(array('api_key' => 'my_api_key'));
$response = $sift->track('$transaction', array(
'$user_id' => '23056',
'$user_email' => 'buyer@gmail.com',
'$seller_user_id' => '2371',
'$seller_user_email' => 'seller@gmail.com',
'$transaction_id' => '573050',
'$currency_code' => 'USD',
'$amount' => 15230000,
'$time' => 1327604222,
'trip_time' => 930,
'distance_traveled' => 5.26,
));
$sift = new SiftClient(array('api_key' => 'my_api_key'));
$response = $sift->label('23056', array(
'$is_bad' => true,
'$abuse_type' => 'promotion_abuse'
));
$sift = new SiftClient(array('api_key' => 'my_api_key'));
$response = $sift->unlabel('23056', array('abuse_type' => 'content_abuse'));
$sift = new SiftClient(array('api_key' => 'my_api_key'));
$response = $sift->score('23056');
$response->body['scores']['payment_abuse']['score']; // => 0.030301357270181357
$sift = new SiftClient(array('api_key' => 'my_api_key', 'account_id' => 'my_account_id'));
$response = $sift->getWorkflowStatus('my_run_id');
$response->body['state']; // => "running"
$sift = new SiftClient(array('api_key' => 'my_api_key', 'account_id' => 'my_account_id'));
$response = $sift->getUserDecisions('example_user');
$response->body['decisions']['account_abuse']['decision']['id']; // => "ban_user"
$sift = new SiftClient(array('api_key' => 'my_api_key', 'account_id' => 'my_account_id'));
$response = $sift->getOrderDecisions('example_order');
$response->body['decisions']['payment_abuse']['decision']['id']; // => "ship_order"
Run the tests from the project root with PHPUnit like this:, (*8)
phpunit --bootstrap vendor/autoload.php test
Update composer.json to reflect the new version, as well as any
new requirements then merge changes into master., (*9)
Create a new release with the version number and use it as the description. Packagist will automatically deploy a new package via the configured webhook., (*10)
MIT, (*11)
Sift Science PHP library
MIT
php fraud sift science sift