Skip to content

Instantly share code, notes, and snippets.

@ObjectIsAdvantag
Last active June 6, 2016 04:44
Show Gist options
  • Save ObjectIsAdvantag/32a42508464e765b8d5c74dac785ecb1 to your computer and use it in GitHub Desktop.
Save ObjectIsAdvantag/32a42508464e765b8d5c74dac785ecb1 to your computer and use it in GitHub Desktop.
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
# Note that I am in 212 rooms currently
> curl -X GET -H "Authorization: Bearer $SPARK_TOKEN" "https://api.ciscospark.com/v1/rooms?max=1000" | jq ".items | length"
212
# Let's pick a very verbose room
> curl -X GET -H "Authorization: Bearer $SPARK_TOKEN" "https://api.ciscospark.com/v1/rooms?max=1000" | jq '.items[] | select(.title | contains("spark4devs"))'
{
"id": "Y2lzY29zcGFyazovL3VzL1JPT00vZDJmZGUwOTAtOWQwYy0xMWU1LWFlZWQtMjE3NmZkY2Q4YTU4",
"title": "#spark4devs - Public Support for Cisco Spark API",
"type": "group",
"isLocked": true,
"lastActivity": "2016-05-26T09:24:59.365Z",
"created": "2015-12-07T18:03:30.969Z"
}
# Getting the Room Id from the Spark API identifier
> echo "Y2lzY29zcGFyazovL3VzL1JPT00vZDJmZGUwOTAtOWQwYy0xMWU1LWFlZWQtMjE3NmZkY2Q4YTU4" | base64 --decode
ciscospark://us/ROOM/d2fde090-9d0c-11e5-aeed-2176fdcd8a58
# Number of messages by default
> ROOM_ID="Y2lzY29zcGFyazovL3VzL1JPT00vZDJmZGUwOTAtOWQwYy0xMWU1LWFlZWQtMjE3NmZkY2Q4YTU4"
> curl -X GET -H "Authorization: Bearer $SPARK_TOKEN" "https://api.ciscospark.com/v1/messages?roomId=$ROOM_ID" | jq ".items | length"
50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment