Skip to content

Instantly share code, notes, and snippets.

View chucknado's full-sized avatar

Charles Nadeau chucknado

View GitHub Profile
@chucknado
chucknado / update_package.py
Last active January 6, 2017 22:46
A Python script for the REST API tutorial, "Automating your first localization handoff (Help Center)," at https://support.zendesk.com/hc/en-us/articles/203691406
import os
import glob
import json
import requests
from bs4 import BeautifulSoup, Comment
def main():
subdomain = 'your_subdomain' # setting
email = 'your_email' # setting
@chucknado
chucknado / search.py
Last active October 20, 2020 14:52
A Python script for the article "Zendesk REST API tutorial: Searching" at https://support.zendesk.com/hc/en-us/articles/203691406
from urllib.parse import urlencode
import requests
credentials = 'your_zendesk_email', 'your_zendesk_password'
session = requests.Session()
session.auth = credentials
params = {
'query': 'type:ticket status:open',
@chucknado
chucknado / search.pl
Last active April 30, 2019 19:45
A Perl script for the article "Zendesk REST API tutorial: Searching" at https://support.zendesk.com/hc/en-us/articles/203691406
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use MIME::Base64;
use URI::Escape;
my $credentials = encode_base64('your_email_address:your_password');
my %params = (
@chucknado
chucknado / change_author.pl
Last active August 29, 2015 14:23
A Perl script for the article "Changing the author of a Help Center article" at https://support.zendesk.com/hc/en-us/articles/205815128
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use MIME::Base64;
# Settings
my $article_id = your_article_id;
my $updated_author_id = your_user_id;
my $zendesk_subdomain = 'your_zendesk_subdomain';
@chucknado
chucknado / change_author.py
Last active August 29, 2015 14:23
A Python script for the article "Changing the author of a Help Center article" at https://support.zendesk.com/hc/en-us/articles/205815128
import json
import requests
# Settings
article_id = your_article_id
updated_author_id = your_user_id
zendesk_subdomain = 'your_zendesk_subdomain'
email = 'your_user_email'
password = 'your_user_password'
@chucknado
chucknado / import_users.py
Last active August 29, 2015 14:24
A Python script for the article "Importing users with the Zendesk API" at https://support.zendesk.com/hc/en-us/articles/206155718
import json
import xlrd
import requests
session = requests.Session()
session.headers = {'Content-Type': 'application/json'}
session.auth = 'your_zd_email', 'your_zd_password'
url = 'https://your_subdomain.zendesk.com/api/v2/users/create_many.json'
@chucknado
chucknado / search_kb.js
Last active August 29, 2015 14:25
A script for for the article "Adding KB search to your website with AJAX" at https://support.zendesk.com/hc/en-us/articles/206287378
document.getElementById('search_btn').addEventListener('click', search_kb, false);
function search_kb(event) {
event.preventDefault();
var search_string = encodeURIComponent(document.getElementById('query').value);
var url = 'https://your_subdomain.zendesk.com/api/v2/help_center/articles/search.json?query=' + search_string;
var my_request = new XMLHttpRequest();
my_request.open('get', url, true);
my_request.onload = show_results;
my_request.onerror = show_error;
@chucknado
chucknado / search_kb_jquery.js
Last active August 29, 2015 14:25
A jQuery version of a script for the article "Adding KB search to your website with AJAX" at https://support.zendesk.com/hc/en-us/articles/206287378
$('#search_btn').click(function(event) {
event.preventDefault();
var search_string = encodeURIComponent($('#query').val());
$.ajax({
url: 'https://your_subdomain.zendesk.com/api/v2/help_center/articles/search.json?query=' + search_string,
contentType: 'application/json',
success: show_results,
error: show_error
});
});
@chucknado
chucknado / list_followers.py
Last active August 12, 2016 17:50
A Python script for "Zendesk API tutorial: Listing the followers of a KB section" at https://support.zendesk.com/hc/en-us/articles/206340488
import argparse
import requests
parser = argparse.ArgumentParser()
parser.add_argument("id")
args = parser.parse_args()
hc_id = args.id
session = requests.Session()
@chucknado
chucknado / list_followers.pl
Last active August 29, 2015 14:25
A Perl script for "Zendesk API tutorial: Listing the followers of a KB section" at https://support.zendesk.com/hc/en-us/articles/206340488
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use MIME::Base64;
my $num_args = $#ARGV + 1;
if ($num_args != 1) {
print "Usage error: list_followers.pl hc_id\n";
exit;