This module allows easy access of Zendesk API from within Zend Framework 2 application.
Installation is supported via Composer:
- Add
"mtymek/mt-zendesk-api":"dev-master"
to yourcomposer.json
file and runphp composer.phar update
. - Add
MtZendeskApi
to yourconfig/application.config.php
file under the modules key.
- Copy
config/zendesk.local.php.dist
file into your main application'sconfig/autoload' directory, rename it to
zendesk.local.php` - Replace placeholder values with subdomain, username and API token read from Zendesk settings page
Example:
return [
'zendesk' => [
'subdomain' => 'mycompany',
'username' => '[email protected]',
'token' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
],
];
Once configured, MtZendeskApi will expose Zendesk API client using ServiceManager. Example usage (from controller):
$client = $this->getServiceLocator()->get('Zendesk\API\Client');
$newTicket = $client->tickets()->create(
[
'subject' => 'Question to Support Team',
'tags' => ['tag1', 'tag2'],
'requester' => [
'email' => '[email protected]',
],
'comment' => [
'body' => "Ticket body"
],
'priority' => 'normal'
]
);