Skip to content

Instantly share code, notes, and snippets.

View chucknado's full-sized avatar

Charles Nadeau chucknado

View GitHub Profile
@chucknado
chucknado / scripts.js
Last active August 16, 2018 08:57
Sample script for Zendesk API tutorial named "Making cross-origin, browser-side API requests" at https://help.zendesk.com/hc/en-us/articles/115005580188
function init() {
// reset page
document.getElementById('error-msg').style.display = "none";
document.getElementById('details').style.display = "none";
var url = window.location.href;
if (url.indexOf('your_redirect_url') !== -1) {
if (url.indexOf('access_token=') !== -1) {
var access_token = readUrlParam(url, 'access_token');
localStorage.setItem('zauth', access_token);
@chucknado
chucknado / list_posts.py
Last active February 14, 2018 00:24
Completed script for "Getting large datasets with the Zendesk API and Python" at https://support.zendesk.com/hc/en-us/articles/211713848
import pickle
import time
import requests
credentials = 'your_zendesk_email', 'your_zendesk_password'
session = requests.Session()
session.auth = credentials
zendesk = 'your_zendesk_url'
topic_id = 123456
@chucknado
chucknado / update_articles_in_section.py
Last active February 9, 2017 22:13
Update a property of all the articles in a Zendesk Help Center section
import requests
credentials = 'your_zendesk_email', 'your_zendesk_password'
zendesk = 'https://your_subdomain.zendesk.com'
language = 'some_locale'
section_id = 123456
# Configure the list section articles endpoint
endpoint = zendesk + '/api/v2/help_center/{}/sections/{}/articles.json'.format(language, section_id)
@chucknado
chucknado / main.js
Last active January 20, 2017 21:32
A Zendesk app for a tutorial on adding OAuth at https://support.zendesk.com/hc/en-us/articles/205225558
$(function() {
var client = ZAFClient.init();
client.invoke('resize', {width: '100%', height: '400px'});
showStart();
$("#check-token").click(function (event) {
event.preventDefault();
client.invoke('notify', 'Authenticating...');
@chucknado
chucknado / auth.py
Last active January 20, 2017 18:43
A Bottle application for a Zendesk App tutorial called "Add OAuth" at https://support.zendesk.com/hc/en-us/articles/205225558
import os
from urllib.parse import urlencode
import requests
from bottle import route, redirect, request, response, template, run
@route('/auth/asana')
def asana_auth():
params = {
@chucknado
chucknado / iframe.html
Created January 20, 2017 18:34
The iframe of a Zendesk app for the OAuth tutorial at https://support.zendesk.com/hc/en-us/articles/205225558
<html>
<head>
<link href="https://cdn.jsdelivr.net/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="main.css" rel="stylesheet">
</head>
<body>
<div id="content"></div>
<script id="start-hdbs" type="text/x-handlebars-template">
@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 / publish_package.py
Last active January 6, 2017 22:44
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 / restore_articles.py
Created January 4, 2017 23:48
A Python script for the REST API tutorial, "Backing up your knowledge base," at https://help.zendesk.com/hc/en-us/articles/229136947
import os
import requests
from bs4 import BeautifulSoup
# Settings
credentials = 'your_zendesk_email', 'your_zendesk_password'
zendesk = 'https://your_instance.zendesk.com'
backup_folder = '20xx-xx-xx'
@chucknado
chucknado / write_posts.pl
Last active December 13, 2016 03:13
Sample script for "Write large data sets in Excel with Perl" at https://support.zendesk.com/hc/en-us/articles/212356448
#!/usr/bin/perl
use strict;
use warnings;
use Storable;
use Excel::Writer::XLSX;
my $topic_hash_ref = retrieve('my_serialized_data');
my %topic_data = %{ $topic_hash_ref };
my $workbook = Excel::Writer::XLSX->new( 'topic_posts.xlsx' );