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
<?php | |
function post($path, $json) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://site.desk.com$path"); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_USERPWD, "my-email:my-password"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $json); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
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
require 'desk_api' | |
require 'csv' | |
# Create the CSV files | |
cases = CSV.open('./cases.csv', 'wb') | |
interactions = CSV.open('./interactions.csv', 'wb') | |
# Add the headers to the CSV files | |
cases << ['Case #', 'Subject', 'Description', 'Status'] | |
interactions << ['Case #', 'Body', 'Created Date'] |
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
curl -L https://example.desk.com/api/v2/cases/3061/attachments/82558857/url -u agent@example.com:password > my_image.jpg |
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
#!/usr/bin/perl -w | |
use Digest::SHA qw( sha1 hmac_sha1 ); | |
use Crypt::Random qw( makerandom_octet ); | |
use DateTime; | |
use JSON; | |
use Crypt::CBC; | |
use Digest::HMAC; | |
use URL::Encode qw( url_encode_utf8 ); | |
use MIME::Base64::Perl; |
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
# configure the client | |
client = DeskApi::Client.new username: 'support@example.com', password: '$uper$ecretP@ssword', endpoint: 'https://example.desk.com' | |
# create the customer using a plain request | |
resp = client.post('/api/v2/customers', { | |
first_name: 'John', | |
last_name: 'Doe', | |
emails: [{ type: 'home', value: 'jdoe@example.net' }] | |
}) |
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
(function($) { | |
function nextPage(url, callback) { | |
$.get(url, function(data, textStatus, jqXHR) { | |
var cases = $(data).find('.mycases tbody tr') | |
, nextUrl = $(data).find('#pagination a.next_page'); | |
callback(cases); | |
if (nextUrl && nextUrl.attr('href')) nextPage(nextUrl.attr('href'), callback); | |
}, 'html'); |
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
<?php | |
$json = json_encode(array( | |
'_links' => array( | |
'assigned_user' => array( | |
'href' => '/api/v2/users/16096734', | |
'class' => 'user' | |
) | |
) | |
)); |
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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use feature qw(say); | |
use JSON; | |
use WWW::Curl::Easy; | |
my $DeskSite = 'https://example.desk.com'; |
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
<?php | |
$json = json_encode(array( | |
"subject" => "Test", | |
"description" => "testing", | |
"message" => array( | |
"subject" => "Test", | |
"body" => "Test", | |
"direction" => "in", | |
"to" => "support@example.com", |
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
BASE_URL: https://desk-oauth-express.herokuapp.com | |
CONSUMER_KEY: MY_CONSUMER_KEY | |
CONSUMER_SECRET: MY_CONSUMER_SECRET | |
SESSION_SECRET: MY_SESSION_SECRET |