Skip to content

Instantly share code, notes, and snippets.

@loisaidasam
Created February 13, 2017 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loisaidasam/2eab3ac95fbb5f721680704fd8d8f36b to your computer and use it in GitHub Desktop.
Save loisaidasam/2eab3ac95fbb5f721680704fd8d8f36b to your computer and use it in GitHub Desktop.
CLI lunch place chooser, chosen randomly from a foursquare list
#!/bin/bash
API_VERSION="20140401"
CLIENT_ID="YOUR CLIENT ID HERE"
CLIENT_SECRET="YOUR CLIENT SECRET HERE"
LIST_ID="YOUR LIST_ID HERE"
# or if you're in downtown Atlanta you could use mine, based on:
# https://foursquare.com/loisaidasam/list/hifi-lunch-eats--atl-edition
LIST_ID="5873b4bb0b56564a748ca1d5"
URL="https://api.foursquare.com/v2/lists/$LIST_ID?v=$API_VERSION&client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET"
#curl -Ss "$URL" | jq '.response.list.listItems.items'
VENUES=`curl -Ss "$URL" | jq '.response.list.listItems.items'`
NUM_VENUES=`echo "$VENUES" | jq 'length'`
#echo "$NUM_VENUES venues"
# TODO: Fix index error for if it chooses the last one :)
VENUE_NUM=`jot -r 1 0 $NUM_VENUES`
#echo "chose venue num $VENUE_NUM"
#echo "$VENUES" | jq ".[$VENUE_NUM].venue"
NAME=`echo "$VENUES" | jq -r ".[$VENUE_NUM].venue.name"`
echo "How about $NAME?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment