Created
March 7, 2014 00:20
-
-
Save etuchscherer/9402579 to your computer and use it in GitHub Desktop.
Script that can be used for mining test user info via Graph Api.
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
#!/bin/bash | |
# Mine the Facebook Graph API for data. | |
# ////////////////////////////////////////////////// | |
# ////////////// Options ////////////////////////// | |
# ////////////////////////////////////////////////// | |
# | |
# -i Input file. Must contain a list of ids, | |
# separated by line. | |
# -o The output file to write results to. Results | |
# are separated by line breaks, and correspond | |
# to the Input file. | |
# -f Results come back as json. -f specifies the | |
# field to extract | |
# ////////////////////////////////////////////////// | |
# //////////// Examples ////////////////////////// | |
# ////////////////////////////////////////////////// | |
# | |
# Write a group of users ( ids listed in file 'users' ) | |
# email addresses to a file name output.txt | |
# | |
# mine -i users -f email -o output.txt | |
# to a file named foo.txt, run the following command | |
while getopts ":i:f:o:" opt; do | |
case $opt in | |
i) | |
# Sets the input file | |
i=${OPTARG} | |
read -d '' -r -a USERS < $i >&2 | |
;; | |
f) | |
# Sets the field | |
f=${OPTARG} | |
MINER="return this.$f" >&2 | |
;; | |
o) | |
# Output file to write to | |
OUT=${OPTARG} >&2 | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
esac | |
done | |
# your access token | |
TOKEN="355423464522219|49EE8gBcz7AQsIQSb8lAl_DuTPU" | |
for i in "${USERS[@]}" | |
do | |
curl https://graph.facebook.com/$i/?access_token=$TOKEN | jsawk "$MINER" >> $OUT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment