1. Go to this page and download the library: Download adambalan/helpscout-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adambalan / helpscout-api example snippets
use HelpscoutApi\Api\Get\Articles;
use HelpscoutApi\Contracts\ApiKey; // We will pretend we implemented this as ApiKeyValue;
use HelpscoutApi\Contracts\Category; // We will pretend we implemented this as CategoryValue;
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://docsapi.helpscout.net/v1/',
]);
$apiKey = new ApiKeyValue('xxxxxxxxxx');
$categoryValue = new CategoryValue('12345667');
$articles = new Article($client, $apiKey);
$articleJSON = $articles->getAll($categoryValue);
// Do something with $articleJSON.
use HelpscoutApi\Api\Get\Articles;
use HelpscoutApi\Contracts\ApiKey; // We will pretend we implemented this as ApiKeyValue;
use HelpscoutApi\Contracts\Category; // We will pretend we implemented this as CategoryValue;
use HelpscoutApi\Params\Article as ArticleParams;
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://docsapi.helpscout.net/v1/',
]);
$apiKey = new ApiKeyValue('xxxxxxxxxx');
$categoryValue = new CategoryValue('12345667');
// You can set the url params that come back as `?sort=number&status=number`:
$articleParams = new ArticleParams();
$articleParams->sort('number');
$articleParams->status('name');
$articles = new Article($client, $apiKey);
// We then pass $articleParams
$articleJSON = $articles->getAll($categoryValue, $articleParams);
// Do something with $articleJSON.
use HelpscoutApi\Api\Post\Article;
use HelpscoutApi\Contracts\ApiKey; // We will pretend we implemented this as ApiKeyValue;
use HelpscoutApi\Contracts\ArticlePostBody; // We will pretend we implemented this as ArticlePostBody;
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://docsapi.helpscout.net/v1/',
]);
$apiKey = new ApiKeyValue('xxxxxxxxxx');
$articlePostBody->collectionID('123');
$articlePostBody->name('article name');
$articlePostBody->text('something');
$article = new Article($client, $apiKey);
$article->create($articlePostBodyValue);
// This will return a response, see https://developer.helpscout.com/docs-api/articles/create/
// for more information.
use HelpscoutApi\Api\Delete\Article;
use HelpscoutApi\Contracts\ApiKey;
use HelpscoutApi\Contracts\Article as ArticleContract;
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://docsapi.helpscout.net/v1/',
]);
$apiKey = new ApiKeyValue('xxxxxxxxxx');
$articleContract = new ArticleContract('1234');
$article = new Article($client, $apiKey);
$article->delete($articleContract); // Returns the \GuzzleHttp\Psr7\Response
use HelpscoutApi\Api\Post\Article;
use HelpscoutApi\Contracts\ApiKey; // We will pretend we implemented this as ApiKeyValue;
use HelpscoutApi\Contracts\ArticlePostBody; // We will pretend we implemented this as ArticlePostBody;
use HelpscoutApi\Contracts\ArticlePutBody; // We will pretend we implemented this as ArticlePutBody;
use GuzzleHttp\Client;
$client = new Client([
'base_uri' => 'https://docsapi.helpscout.net/v1/',
]);
$apiKey = new ApiKeyValue('xxxxxxxxxx');
$articlePostBody->collectionID('123');
$articlePostBody->name('article name');
$articlePostBody->text('something');
$articlePutBody->id('articleId');
$articlePutBody->articlePostBody($articlePostBody);
$article = new Article($client, $apiKey);
$article->update($articlePutBody);
// This will return a response, see https://developer.helpscout.com/docs-api/articles/update/
// for more information.
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\RequestException;
// ... Set up your article info to be posted, see previous examples.
$promise = $article->createAsync($articlePostBodyValue);
$promise->then(function(ResponseInterface $ri) {
echo $ri->getStatusCode();
},
function(RequestException $e) {
echo $e->getMessage();
});
use HelpscoutApi\Contracts\RequestPool;
use HelpscoutApi\Api\Pool;
// ... Set up your article info to be posted, see previous examples.
$request = $article->createRequest($articlePostBodyValue);
$requestPool->pushRequest($request); // Push the request
$request->setConcurrency(1); // How many should we do before we wait for them all to complete?
$pool = new Pool($client);
$pool->pool($requestPool, function($reason, $index){ ... }, function($response){ ... });
// The first call back function is called when we are rejected.
// The second is optional and only called on success.
use HelpscoutApi\Request\Request;
// See above for creating an article:
$response = $article->create($articlePostBodyValue);
$responseObject = new Request($response);
$responseObject->getLocation(); // Returns the location of the created object.
$responseObject->getContents(); // Returns the contents of the returned body.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.