-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from zendesk/samgavinio/samples-for-helpcente…
…r-section Add support for creating sections and for listing sections for a category
- Loading branch information
Showing
5 changed files
with
188 additions
and
18 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
include('../../vendor/autoload.php'); | ||
|
||
use Zendesk\API\HttpClient as ZendeskAPI; | ||
|
||
/** | ||
* Replace the following with your own. | ||
*/ | ||
|
||
$subdomain = "subdomain"; | ||
$username = "email@example.com"; | ||
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; | ||
|
||
$client = new ZendeskAPI($subdomain); | ||
$client->setAuth('basic', ['username' => $username, 'token' => $token]); | ||
|
||
try { | ||
// Create a new HelpCenter Section | ||
$categoryId = 1; | ||
$section = $client->helpCenter->categories($categoryId)->sections()->create([ | ||
'position' => 1, | ||
'locale' => 'en-us', | ||
'name' => 'Super Hero Tricks', | ||
'description' => 'This section contains a collection of super hero tricks', | ||
]); | ||
echo "<pre>"; | ||
print_r($section); | ||
echo "</pre>"; | ||
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) { | ||
echo $e->getMessage().'</br>'; | ||
} |
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,45 @@ | ||
<?php | ||
|
||
include('../../vendor/autoload.php'); | ||
|
||
use Zendesk\API\HttpClient as ZendeskAPI; | ||
|
||
/** | ||
* Replace the following with your own. | ||
*/ | ||
|
||
$subdomain = "subdomain"; | ||
$username = "email@example.com"; | ||
$token = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; | ||
|
||
$client = new ZendeskAPI($subdomain); | ||
$client->setAuth('basic', ['username' => $username, 'token' => $token]); | ||
|
||
try { | ||
// Find all helpcenter sections | ||
$sections = $client->helpCenter->sections()->findAll(); | ||
echo "<pre>"; | ||
print_r($sections); | ||
echo "</pre>"; | ||
|
||
// Find all helpcenter sections with a specific locale | ||
$sections = $client->helpCenter->sections()->setLocale('en-us')->findAll(); | ||
echo "<pre>"; | ||
print_r($sections); | ||
echo "</pre>"; | ||
|
||
// Find all helpcenter sections within a specific category | ||
$categoryId = 204009948; | ||
$sections = $client->helpCenter->categories($categoryId)->sections()->findAll(); | ||
echo "<pre>"; | ||
print_r($sections); | ||
echo "</pre>"; | ||
|
||
// Find all helpcenter sections with a specific locale in a category | ||
$sections = $client->helpCenter->categories($categoryId)->sections()->setLocale('en-us')->findAll(); | ||
echo "<pre>"; | ||
print_r($sections); | ||
echo "</pre>"; | ||
} catch (\Zendesk\API\Exceptions\ApiResponseException $e) { | ||
echo $e->getMessage().'</br>'; | ||
} |
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
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