Skip to content

Commit

Permalink
Demonstrate how to get help center articles using the php client
Browse files Browse the repository at this point in the history
- Note that this will not work unless you enable help center for your account
- Indicate such in error handling as well as other standard cause due to
  incorrect credentials
- Evidently token access is the supported approach
  • Loading branch information
token-cjg committed Sep 23, 2024
1 parent 276fb53 commit 5d65054
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions samples/articles/getArticles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
require_once __DIR__ . '/../../vendor/autoload.php';

use Zendesk\API\HttpClient as ZendeskAPI;

$subdomain = "subdomain";
$username = "email@example.com"; // replace this with your registered email
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your token

$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);

$help_center = new Zendesk\API\Resources\HelpCenter($client);

try {
$query = $help_center->articles()->findAll();
foreach ($query as $UserData) {
echo "<pre>";
print_r($UserData);
echo "</pre>";
}
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo 'You may either have not enabled Help Center or you may have entered incorrect credentials. Make sure to change the $subdomain, $username, and $token variables in this file.';
}

0 comments on commit 5d65054

Please sign in to comment.