2017 © Pedro Peláez
 

library frontapp

Super-simple, minimum abstraction FrontApp API wrapper

image

drewm/frontapp

Super-simple, minimum abstraction FrontApp API wrapper

  • Monday, October 17, 2016
  • by drewm
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,607 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 1 Versions
  • 7 % Grown

The README.md

FrontApp API client

Super-simple, minimum abstraction Front API wrapper, in PHP., (*1)

In the style of my MailChimp wrapper, this lets you get from the FrontApp API docs to the code as directly as possible., (*2)

Requires PHP 5.4 and curl., (*3)

Installation

You can install frontapp using Composer:, (*4)

composer require drewm/frontapp

You will then need to: * run composer install to get these dependencies added to your vendor directory * add the autoloader to your application with this line: require("vendor/autoload.php"), (*5)

Examples

Start by use-ing the class and creating an instance with your API key, (*6)

use \DrewM\FrontApp\FrontApp;

$FrontApp = new FrontApp('abc123abc123abc123abc123abc123');

Then, list all your inboxes (with a get on the inboxes method), (*7)

$result = $FrontApp->get('inboxes');

print_r($result);

Create an inbox (with a post to the inboxes method):, (*8)

$result = $FrontApp->post("inboxes", [
                'name' => 'Support'
            ]);

print_r($result);

Update a channel member with more information (using patch to update):, (*9)

$channel_id = 'cha_123';

$result = $FrontApp->patch("channels/$channel_id", [
                'settings' => [ 'webhook_url' => 'https://example.com/hook' ]
            ]);

print_r($result);

Remove a contact using the delete method:, (*10)

$contact_id = 'ctc_123';

$FrontApp->delete("contacts/$contact_id");

Quickly test for a successful action with the success() method:, (*11)

$result = $FrontApp->get('inboxes');

if ($FrontApp->success()) {
    print_r($result);   
} else {
    echo $FrontApp->getLastError();
}

Troubleshooting

To get the last error returned by either the HTTP client or by the API, use getLastError():, (*12)

echo $FrontApp->getLastError();

For further debugging, you can inspect the headers and body of the response:, (*13)

print_r($FrontApp->getLastResponse());

If you suspect you're sending data in the wrong format, you can look at what was sent to FrontApp by the wrapper:, (*14)

print_r($FrontApp->getLastRequest());

The Versions

17/10 2016

dev-master

9999999-dev https://github.com/drewm/frontapp

Super-simple, minimum abstraction FrontApp API wrapper

  Sources   Download

MIT

The Requires

  • php >=5.4
  • ext-curl *