Batch
This library includes several classes and methods to implement the different Batch API calls. You will find the
documentation of the different API here., (*1)
Installation
Composer installation
To install Google Analytics, you first need to install Composer, a Package Manager
for PHP, following those few steps:, (*2)
curl -s https://getcomposer.org/installer | php
You can run this command to easily access composer from anywhere on your system:, (*3)
sudo mv composer.phar /usr/local/bin/composer
Batch Installation
You can install this package using composer
by running the command below., (*4)
php /usr/local/bin/composer/composer.phar require matchpint/batch
You can also add matchpint\batch
to your the require of your composer.json
as below, (*5)
{
"name": "domain/your_project",
"require": {
"matchpint/batch": "~1"
}
}
and run, (*6)
php /usr/local/bin/composer/composer.phar update
Prerequisites
This library implements the APIs provide by batch.com.
You must get your API Key and Rest Key before using this project., (*7)
Usage
Regular usage
- Initialisation
use Batch\BatchCustomData;
$batchCustomData = new BatchCustomData($yourApiKey, $yourRestKey);
- Write as an array the body that you want to send to Batch (if needed)
$body = [
"u.field_name" => "newValue",
"ut.tags" => [
"$add" => ["newTag"]
]
];
-
Send the request to Batch using the function corresponding to the endpoint you need., (*8)
$batchCustomData->send($customUserId, $body, FALSE);
When you have two projects (iOS and Android)
In case you have two Batch applications (iOS and Android), you probably want to make sure to send a call to each applications., (*9)
You will find for each client an version of this class implementing calls for two applications (iOS / Android)., (*10)
Convention: The client {Client}
will have a IosAndroid{Client}
equivalent that is implementing this., (*11)
Functionality
Custom Data API
Class: Batch\CustomData
, (*12)
-
Update data: send(customUserId: string, values: array, override: boolean)
, (*13)
-
customUserId
: Batch Custom Id described here for iOS and here for Android.
-
values
: Array containing the values that should be sent to the API as described here.
-
override
: Instead of merging the data we already have for a user, the existing data will be deleted and replaced by the incoming data (default to FALSE).
-
Update Bulk data: sendBulk(body: array)
, (*14)
-
body
: Body of the request describe here
-
Delete member: TODO, (*15)
Class Batch\IosAndroidCustomData
, (*16)
Transactional API
Class: Batch\TransactionalAPI
, (*20)
-
Send a push notification: sendPush(pushIdentifier, recipients, message, optionalFields)
, (*21)
-
pushIdentifier
: (STRING) Name given to a given kind of push notification. ex: referral
-
recipients
: (ARRAY[STRING[]]) Set of recipients ONLY ACCEPTED : ["tokens", "custom_ids", "install_ids"]. ex: ["custom_ids" => [162446]]
-
message
: (STRING[]) Message to send to the user, must contain a title and a boy. ex: ["title" => "XXX", "body" => "XXXX"]
-
optionalFields
: (ARRAY) Any kind of optional field that can precise push notification parameters. For more detailed information see here
Class Batch\IosAndroidTransactionalData
, (*22)
Campaigns API
TODO:, (*24)