Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

asm-helpful/helpful-php

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

helpful-php

Official Helpful API library client for PHP

This library is generated by alpaca

Installation

Make sure you have composer installed.

Add the following to your composer.json

{
    "require": {
        "helpful/helpful": "*"
    }
}

Update your dependencies

$ php composer.phar update

This package follows the PSR-0 convention names for its classes, which means you can easily integrate these classes loading in your own autoloader.

Versions

Works with [ 5.4 / 5.5 ]

Usage

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

// Then we instantiate a client (as shown below)

Build a client

Using this api without authentication gives an error

Basic authentication
$auth = array('username' => 'pksunkara', 'password' => 'password');

$client = new Helpful\Client($auth, $clientOptions);
Oauth access token
$client = new Helpful\Client('1a2b3', $clientOptions);
Oauth client secret
$auth = array('client_id' => '09a8b7', 'client_secret' => '1a2b3');

$client = new Helpful\Client($auth, $clientOptions);

Client Options

The following options are available while instantiating a client:

  • base: Base url for the api
  • api_version: Default version of the api (to be used in url)
  • user_agent: Default user-agent for all requests
  • headers: Default headers for all requests
  • request_type: Default format of the request body

Response information

All the callbacks provided to an api call will receive the response as shown below

$response = $client->klass('args')->method('args', $methodOptions);

$response->code;
// >>> 200

$response->headers;
// >>> array('x-server' => 'apache')
JSON response

When the response sent by server is json, it is decoded into an array

$response->body;
// >>> array('user' => 'pksunkara')

Method Options

The following options are available while calling a method of an api:

  • api_version: Version of the api (to be used in url)
  • headers: Headers for the request
  • query: Query parameters for the url
  • body: Body of the request
  • request_type: Format of the request body

Request body information

Set request_type in options to modify the body accordingly

RAW request

When the value is set to raw, don't modify the body at all.

$body = 'username=pksunkara';
// >>> 'username=pksunkara'
JSON request

When the value is set to json, JSON encode the body.

$body = array('user' => 'pksunkara');
// >>> '{"user": "pksunkara"}'

Accounts api

These are like organizations which use Helpful.

$accounts = $client->accounts();
List all accounts (GET /accounts)

All the accounts the user has access to

$response = $accounts->all($options);
Retrieve an account (GET /accounts/:account_id)

Get an account the user has access to

The following arguments are required:

  • account_id: Identifier of the account
$response = $accounts->get("b3ebe711-755e-4a91-b8d2-0cc028827bcf", $options);
Update an account (PATCH /accounts/:account_id)

Update an account the user has access to

The following arguments are required:

  • account_id: Identifier of the account
$response = $accounts->update("b3ebe711-755e-4a91-b8d2-0cc028827bcf", $options);

People api

People who operate or interacted with the account

$people = $client->people();
List all people (GET /accounts/:account_id/people)

List all people in the account the user has access to

The following arguments are required:

  • account_id: Identifier of the account
$response = $people->all("b3ebe711-755e-4a91-b8d2-0cc028827bcf", $options);

Conversations api

Conversations in an account

$conversations = $client->conversations();
List all conversations (GET /accounts/:account_id/conversations)

List all conversations in an account the user has access to

The following arguments are required:

  • account_id: Identifier of the account
$response = $conversations->all("b3ebe711-755e-4a91-b8d2-0cc028827bcf", "false", $options);
Create a conversation (POST /accounts/:account_id/conversations)

Create an empty conversation in account the user has access to

The following arguments are required:

  • account_id: Identifier of the account
$response = $conversations->create("b3ebe711-755e-4a91-b8d2-0cc028827bcf", $options);
Retrieve a conversation (GET /conversations/:conversation_id)

Get a conversation the user has access to

The following arguments are required:

  • conversation_id: Identifier of the conversation
$response = $conversations->get("10ce24de-23f6-433f-9a71-255cffffa96f", $options);

Messages api

Messages in a conversation

$messages = $client->messages();
Retrieve a message (GET /messages/:message_id)

Get a message the user has access to

The following arguments are required:

  • message_id: Identifier of the message
$response = $messages->get("33314e4e-baf5-4b33-be72-112ed86701fd", $options);

Contributors

Here is a list of Contributors

TODO

License

MIT

Bug Reports

Report here.

Contact

Pavan Kumar Sunkara (pavan.sss1991@gmail.com)

About

Support comes from people, not software

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.