From 3a50ecd64ba0e1d9d512f96d43ebe819ce036c5f Mon Sep 17 00:00:00 2001 From: Christopher Goddard Date: Mon, 23 Sep 2024 14:07:17 +1000 Subject: [PATCH] Demonstrate how to get help center articles by section_id (#536) - 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 --- samples/helpcenter/findArticles.php | 3 +- .../helpcenter/findArticlesBySectionId.php | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 samples/helpcenter/findArticlesBySectionId.php diff --git a/samples/helpcenter/findArticles.php b/samples/helpcenter/findArticles.php index 2b289036a..67b1af8da 100644 --- a/samples/helpcenter/findArticles.php +++ b/samples/helpcenter/findArticles.php @@ -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 "
";
     print_r($articles);
diff --git a/samples/helpcenter/findArticlesBySectionId.php b/samples/helpcenter/findArticlesBySectionId.php
new file mode 100644
index 000000000..29dff547c
--- /dev/null
+++ b/samples/helpcenter/findArticlesBySectionId.php
@@ -0,0 +1,29 @@
+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 "
";
+    print_r($articles);
+    echo "
"; +} catch (\Zendesk\API\Exceptions\ApiResponseException $e) { + echo $e->getMessage().'
'; +}