-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demonstrate how to get help center articles by section_id
- We need to wrap the client in a help center resource, otherwise the request will not have what it needs to retrieve all articles, rather than a given section - Provide a specific example demonstrating how to list articles by section_id
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'; | ||
} |