Download the PHP package omnisend/php-sdk without Composer
On this page you can find all versions of the php package omnisend/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-sdk
Omnisend PHP-SDK
Simple Omnisend API v3 wrapper in PHP.
Omnisend API v3 documentation can be found here.
Requires PHP > 5.3, cURL or allow_url_fopen
to be enabled.
Installation
You can install Omnisend PHP-SDK by either using Composer either by downloading and including it manually.
Install using a composer
-
Run these commands:
- Add the autoloader to your application:
Note: check and correct, if needed, "vendor/autoload.php" path.
Install manually
Download the Omnisend.php
file and include it manually:
Note: check and correct if needed "Omnisend.php" path.
Available methods & options
Creating instance with your API Key and options (optional)
Available options:
Name | Type | Description |
---|---|---|
timeout | int | Timeout. If not passed - will be calculated depending on PHP max_execution_time |
verifySSL | bool | Default - true. Enable (true) or disable (false) SSL verification. |
Available methods
endpoint
- endpoint url (ex. 'contacts', 'products/prod123'). See documentation for available endpoints.
queryParams
- array of query parameters
fields
- array of fields
- getSnippet() - returns html snippet code
- get(endpoint, queryParams) - make
GET
request. - push(endpoint, fields, queryParams) - makes
POST
request. If error occurs (resource exists in Omnisend) - makesPUT
request. This method can be used if you don't know if item exists in Omnisend.queryParams
- optional. - post(endpoint, fields, queryParams) - make
POST
request. Used to create new item in Omnisend. Will return an error if an item already exists in Omnisend.queryParams
- optional. - put(endpoint, fields, queryParams) - make
PUT
request. Used to replace item in Omnisend. Will return an error if an item doesn't exists in Omnisend.queryParams
- optional. - patch(endpoint, fields, queryParams) - make
PATCH
request. Used to update item in Omnisend. Will return an error if an item doesn't exists in Omnisend.queryParams
- optional. - delete(endpoint, queryParams) - make
DELETE
request. Used to delete item in Omnisend. Will return an error if an item doesn't exists in Omnisend.queryParams
- optional.
Responses
Each method will return false
in case of an error, array
(see documentation for responses) or true
(for empty body (204) responses) in case of a success.
So you can easily check if a request was successful:
In case of a failed request, you can get an error description with lastError()
:
Output will be an array with:
- error - error description
- statusCode - HTTP response status code
- fields - optional - array of missing required, incorrect or incorrectly formatted
fields
(passed with a request)
Example:
Examples
-
Create an instance with your API key and options (optional)
-
Make a request, for example, create a new contact in Omnisend:
- Check if a request was successful:
See more examples in examples/examples.php
All versions of php-sdk with dependencies
ext-curl Version *