1. Go to this page and download the library: Download intercom/intercom-php 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/ */
intercom / intercom-php example snippets
namespace Example;
use Intercom\IntercomClient;
use Intercom\AiContent\Requests\CreateContentImportSourceRequest;
use Intercom\AiContent\Types\CreateContentImportSourceRequestStatus;
$client = new IntercomClient(
token: '<token>',
);
$client->aiContent->createContentImportSource(
new CreateContentImportSourceRequest([
'syncBehavior' => 'api',
'status' => CreateContentImportSourceRequestStatus::Active->value,
'url' => 'url',
]),
);
use Intercom\IntercomClient;
$client = new IntercomClient(
'<token>',
['baseUrl' => 'https://api.example.com'],
);
$items = $client->articles->list(['limit' => 10]);
foreach ($items as $item) {
var_dump($item);
}
foreach ($items->getPages() as $page) {
foreach ($page->getItems() as $pageItem) {
var_dump($pageItem);
}
}
use Intercom\IntercomClient;
// Create a custom Guzzle client with specific configuration.
$customClient = new \GuzzleHttp\Client([
'timeout' => 5.0,
]);
// Pass the custom client when creating an instance of the class.
$client = new IntercomClient(options: [
'client' => $customClient
]);
// You can also utilize the same technique to leverage advanced customizations to the client such as adding middleware
$handlerStack = \GuzzleHttp\HandlerStack::create();
$handlerStack->push(MyCustomMiddleware::create());
$customClient = new \GuzzleHttp\Client(['handler' => $handlerStack]);
// Pass the custom client when creating an instance of the class.
$client = new IntercomClient(options: [
'client' => $customClient
]);
$response = $client->articles->create(
...,
options: [
'maxRetries' => 0 // Override maxRetries at the request level
]
);