Skip to content

Instantly share code, notes, and snippets.

View ObjectIsAdvantag's full-sized avatar

Stève Sfartz ObjectIsAdvantag

View GitHub Profile
# To add a comment to this gist via Postman :
POST https://api.github.com/gists/054ac70210d3c5e246db/comments
> Content-Type: application/json
> Authorization: token 8432627eacef6b3da4c1e2530986c66ZZZZZZZ
{
"body": "My comment from the API Workshop by Cisco DevNet"
}
# Get the whole Postman collection :
@ObjectIsAdvantag
ObjectIsAdvantag / outgoing-get-queryparameters.py
Last active April 17, 2016 12:23
Tropo outgoing GET query parameters
import urllib2
log( "v20160417 - 0602" )
answer()
say( "Welcome to the python Yahoo weather reader" )
log( "outgoing call: before" )
urlRead = urllib2.urlopen( "http://requestb.in/zd4mlazd" + "?input=hello" )
@ObjectIsAdvantag
ObjectIsAdvantag / outgoing-post-urlencoded.py
Last active April 17, 2016 12:21
Tropo Outgoing POST - application/x-www-form-urlencoded
import urllib
import urllib2
version = "v20160417 - 0702"
log( version )
answer()
say( "Welcome to the python v" + version )
@ObjectIsAdvantag
ObjectIsAdvantag / outgoing-post-json.py
Last active April 17, 2016 12:22
Tropo outgoing POST application/json
import json
import urllib2
version = "v20160417 - 0720"
log( version )
webhook = "http://requestb.in/zd4mlazd"
answer()
@ObjectIsAdvantag
ObjectIsAdvantag / sms-end2end-test.js
Last active May 25, 2016 16:03
Tropo Script which test SMS end-to-end and bi-directional SMS connectivity for Europe
// Is it an incoming call ?
if (currentCall) {
log("TROPO_EU_TESTERS, incoming call");
log("TROPO_EU_TESTERS, callId: " + currentCall.id);
log("TROPO_EU_TESTERS, sessionId: " + currentCall.sessionId);
if (currentCall.channel == "VOICE") {
log("TROPO_EU_TESTERS, incoming call, network:VOICE");
say("Thanks for joining Tropo Europe Testers service.");
wait(1000);
@ObjectIsAdvantag
ObjectIsAdvantag / send-sms-script.js
Created May 24, 2016 07:58
Tropo script which sends an SMS
call(phonenumber, { network: "SMS" });
say (msg);
@ObjectIsAdvantag
ObjectIsAdvantag / tropo-logs-to-spark.js
Last active May 27, 2016 12:52
Tropo logs sent to Spark (via an Incoming integration)
// This function writes the log parameter to a Spark Room
// Invoke this function from the Tropo token-url with the "sparkIntegration" parameter set to the incoming Webhook ID you'll have prepared
function log2spark(newLogEntry) {
log("TROPO-LOGS-TO-SPARK: checking integration is well defined");
if (!sparkIntegration) {
log("TROPO-LOGS-TO-SPARK: integration not defined, cannot send request to spark");
throw { message: ("no incoming integration identifier") };
}
log("TROPO-LOGS-TO-SPARK: integration defined, continuing");
@ObjectIsAdvantag
ObjectIsAdvantag / tropo-post-request.js
Last active December 27, 2016 19:38
POST from TROPO in javascript
// Example of a POST request sent from the Tropo scripting platform
// Note that this example comes from : https://support.tropo.com/hc/en-us/articles/206241213-REST-POST-and-GET-in-each-Scripting-language
//
// Quick setup :
// - go to http://requestb.in and create a new POST bin
// - create a tropo scripting application with this gist source
// https://gist.github.com/ObjectIsAdvantag/9ced65903766cfba7ba1760df2fb394a/raw/tropo-post-request.js
// - invoke the tropo application via its text or voice token URL
// do not forget to add a requestBinId query parameter
// ex : https://api.tropo.com/1.0/sessions?action=create&token=XXXXXXXXXXXXXXXX&requestBinId=1k6xjg51
@ObjectIsAdvantag
ObjectIsAdvantag / spark-count.sh
Last active June 6, 2016 04:44
Computing defaults for Cisco Spark
#!/bin/bash
#
# note: jq is a lightweight and flexible command-line JSON processor, https://stedolan.github.io/jq/manual/
> SPARK_TOKEN="xxxxxxxxxxxxxxxxxxxxxx"
# Number of rooms by default
> curl -X GET -H "Authorization: Bearer $SPARK_TOKEN" "https://api.ciscospark.com/v1/rooms" | jq ".items | length"
100
@ObjectIsAdvantag
ObjectIsAdvantag / spark-onboarding.js
Last active May 29, 2016 12:59
Tropo script to onboard new users into Spark
//
// Spark Logging Library
//
// Factory for the Spark Logging Library, with 2 parameters
// - the name of the application will prefix all your logs,
// - the Spark Incoming integration (to which logs will be posted)
// To create an Incoming Integration
// - click integrations in the right pane of a Spark Room (Example : I create a dedicated "Tropo Logs" room)