double-opt-in/cli-client-php

This is a client api for command line as a reference implementation for the Double-Opt-in client api.

1.0.3 2015-06-24 06:52 UTC

README

Latest Stable Version Latest Unstable Version License Total Downloads

This is a demonstration package for die Client API in PHP for the double-opt.in service.

You get an console application to manage your double-opt.in account for a site.

Installation

Add to your composer.json following lines

"require": {
	"double-opt-in/cli-client-php": "~1.0"
}

Usage

You can call vendor/bin/doi-cli to see all your options and commands. It is a symfony console application. So just ask when you do not understand what is going on there. Or use the manual for symfony console component.

Preparation

This is just for demonstration, so to configure the console application is a bit hard. You have to create a config.php file within the vendor/bin folder with the following content:

<?php

return array(
	'api' => 'https://double-opt.in/api',
	'client_id' => 'YOUR_CLIENT_ID',
	'client_secret' => 'YOUR_CLIENT_SECRET',
	'site_token' => 'YOUR_SITE_TOKEN',
);

This is not so convenient, but it is okay for demonstrating the PHP client api.

Built-in commands

Listing all built-in commands:

$> ./vendor/bin/doi-cli

Logging an action

Retrieving all arguments and options:

$> ./vendor/bin/doi-cli help log

Logging an email with action:

$> ./vendor/bin/doi-cli log register test@example.com

Logging an email with action and scope:

$> ./vendor/bin/doi-cli log register test@example.com --scope="newsletter"

Retrieving all actions

Getting help for the command:

$> ./vendor/bin/doi-cli help actions

Getting actions for email:

$> ./vendor/bin/doi-cli actions test@example.com

Validate an email

Getting help for the command:

$> ./vendor/bin/doi-cli help validate

Validate an email:

$> ./vendor/bin/doi-cli validate test@example.com

Status request

Getting help for the command:

$> ./vendor/bin/doi-cli help status

Retrieving status information:

$> ./vendor/bin/doi-cli status

Possible Result can be like this:

+---------------------+----------------------+
| key                 | value                |
+---------------------+----------------------+
| site                | double-opt.in ipunkt |
| type                | premium              |
| storage_time        | 315360000            |
| credits             | 10857964             |
| soft_quota          | 5000                 |
| hard_quota          | -2500                |
| daily_credits_usage | 253                  |
| unique_hashes       | 17563                |
+---------------------+----------------------+

The extra sugar

If you add the verbose flag -v to a command you can get the current rate limiting information as well. E.g.:

999 / 1000 (new reset in 60 seconds)