alexander-emelyanov/anyoption-api-client

PHP Client for AnyOption platform

v0.1.5 2016-03-17 16:22 UTC

This package is not auto-updated.

Last update: 2024-03-27 20:51:25 UTC


README

Build Status StyleCI Code Climate

This repository contains PHP Client for AnyOption platform.

AnyOption is the world's first and largest trading platform for binary options, one touch options and dozens of other advanced derivatives.

Installation

Install using Composer, doubtless.

$ composer require alexander-emelyanov/anyoption-api-client

Usage

First, you need to create a client object to connect to the AnyOption servers. You will need to acquire an API username and API password for your app first from AnyOption, then pass the credentials to the client object for logging in.

$client = new \AnyOption\ApiClient([
    'apiUser' => [
        'userName' => '<ANYOPTION_USERNAME>',
        'password' => '<ANYOPTION_PASSWORD>'
    ],
    'url' => '<ANYOPTION_URL>'
]);

Also your IP address must be added to whitelist of AnyOption platform. Feel free to contact me for more details.

Assuming your credentials is valid and your IP is whitelisted, you are good to go!

Insert user command

$command = new \AnyOption\Commands\InsertUser([
    'utcOffset' => 0,
    'locale' => 'en',
    'register' => [
        'firstName' => 'John',
        'lastName' => 'Smith',
        'email' => 'john.smith@my.com',
        'mobilePhone' => '493025922774',
        'password' => 'qwerty',
        'password2' => 'qwerty',
        'countryName' => 'DEU',
        'ip' => '127.0.0.1',
        'terms' => '',
    ],
]);

/** @var \AnyOption\Responses\InsertUser $response */
$response = $client->call($command);

Note: full list of allowed countries you can get using:

$countries = \AnyOption\Dictionaries::countries();

GetFTDUsersByDate

$command = new \AnyOption\Commands\GetFTDUsersByDate([
    'locale' => 'en',
    'dateRequest' => date('Y-m-d'),
]);

/** @var \AnyOption\Responses\GetFTDUsersByDate $response */
$response = $client->call($command);

Contribution

You are welcome!

Running tests

You can run unit tests via PHPUnit:

$ vendor/bin/phpunit tests

Note: you should install dev dependencies for this package using

$ composer update --dev