PHP SDK Integration

Getting Started

Register and find the ApiKey at http://2hive.org/project/account

Please download PHP SDK first at https://github.com/2HIVE/php.sdk in order to start. Place it to your project working directory.

Initialization

Before starting you should configure the SDK for your project. Please do this during SDK initialization:

Send2Hive::init($apiKey)

The init() method takes your personal API Key as an argument

Sending Data Example

Please see the following sample code:

require_once('Send2Hive.php');
Send2Hive::init(“54739n7328ea8daс585d658b4d8c6f11”);
Send2Hive::add(array(
    'id'      => '1234567890',
    'type' => 'add_photo',
    'lang' => 'en',
    'content' => array(
        array('img'  => 'http://cdn.example.com/filename.jpg'),
        array('text' => 'Photo description')
    ),
    'context'  => array(
        array('text' => 'Jake, 25 years old'),
        array('text' => 'Reports: 3')
    )
));
Send2Hive::send();

Receiving Data Example

Please see the following sample code:

require_once('Send2Hive.php');

Send2Hive::init(“54739n7328ea8daс585d658b4d8c6f11”);
$response = Send2Hive::get();

print_r($response);

Printing result:

array(
    'id'     => '1234567890',
    'type'   => 'profile',
    'status' => 'disallow',
    'reason' => 'Naked body',
    'stat' => array(
        'allow'    => 1,
        'disallow' => 7
    )
);


PHP SDK methods reference

Send2Hive class

Initialization

Constructor Description
Send2Hive::init(string $apiKey) Initializes 2Hive SDK specifically for your project. You can send data for moderation and receive moderation results after this.

Methods

Methods Return Value Description
add(array $data) None Adds a new content for moderation into the list. Please visit http://2hive.org/static/projects/api for detailed description of $data format.
send() None Sends the list of previously added content to 2Hive server.
get() Array.ModerationResult Returns a list moderation results. Please visit http://2hive.org/static/projects/api for detailed description of returned value format.
getError() Integer Returns the code of last request error.
getErrorMessage() String Returns the text description of last request error.