Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate how to get help center articles using the php client #536

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion samples/helpcenter/findArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
$help_center_client = new Zendesk\API\Resources\HelpCenter($client);

try {
// Find all helpcenter categories
$articles = $client->helpCenter->articles()->findAll();
$articles = $help_center_client->articles()->findAll();

echo "<pre>";
print_r($articles);
Expand Down
29 changes: 29 additions & 0 deletions samples/helpcenter/findArticlesBySectionId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

require_once __DIR__ . '/../../vendor/autoload.php';

use Zendesk\API\HttpClient as ZendeskAPI;

/**
* Replace the following with your own.
*/

$subdomain = "subdomain";
$username = "email@example.com";
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv";
$section_id = 10801195364239; // replace this with your section id

$client = new ZendeskAPI($subdomain);
$client->setAuth('basic', ['username' => $username, 'token' => $token]);
$help_center_client = new Zendesk\API\Resources\HelpCenter($client);

try {
// Find all helpcenter category with the given section id
$articles = $help_center_client->sections($section_id)->articles()->findAll();

echo "<pre>";
print_r($articles);
echo "</pre>";
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) {
echo $e->getMessage().'</br>';
}
Loading