Created
July 7, 2011 01:49
-
-
Save oukayuka/1068756 to your computer and use it in GitHub Desktop.
A shell Script that creates/reads/deletes Facebook app test users.
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/sh | |
CLIENT_ID={MY_CLIENT_ID} # Please EDIT | |
CLIENT_SECRET={MY_CLIENT_SECRET} # Please EDIT | |
# handling params | |
MODE="READ" | |
if [ $# -eq 1 ]; then | |
if [ $1 = "-c" ]; then | |
MODE="CREATE" | |
else | |
MODE="INVALID" | |
fi | |
elif [ $# -eq 2 ]; then | |
if [ $1 = "-c" ]; then | |
MODE="CREATE" | |
CREATE_OPTION=$2 | |
elif [ $1 = "-d" ]; then | |
MODE="DELETE" | |
DELETE_USER_ID=$2 | |
else | |
MODE="INVALID" | |
fi | |
elif [ $# -gt 2 ]; then | |
MODE="INVALID" | |
fi | |
if [ $MODE = "INVALID" ]; then | |
echo "Usage: fb_test_users.sh [-c [\"CREATE_OPTION\"]|-d DELETE_USER_ID]" >&2 | |
exit 1 | |
fi | |
# get access_token | |
ACCESS_TOKEN=`curl -L "https://graph.facebook.com/oauth/access_token?client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&grant_type=client_credentials" \ | |
| sed "s/access_token=//g"` 2> /dev/null | |
# operation | |
case $MODE in | |
"CREATE" ) | |
curl -X POST -F access_token=${ACCESS_TOKEN} ${CREATE_OPTION} -L "https://graph.facebook.com/${CLIENT_ID}/accounts/test-users" | |
;; | |
"READ" ) | |
DATA=`curl -L "https://graph.facebook.com/${CLIENT_ID}/accounts/test-users?access_token=${ACCESS_TOKEN}" \ | |
| sed "s/\\\\\//g"` 2> /dev/null | |
echo $DATA | sed "s/,{/,\n{/g" | sed "s/^{\"data\":\[//" | sed "s/\]}$//" \ | |
| sed "s/{\"/{\n \"/g" | sed "s/\"}/\"\n}/g" \ | |
| sed "s/\",\"/\",\n \"/g" | sed "s/\":\"/\": \"/g" | |
;; | |
"DELETE" ) | |
curl -X DELETE -L "https://graph.facebook.com/${DELETE_USER_ID}?access_token=${ACCESS_TOKEN}" | |
;; | |
esac |
Hi oukayuka. can you please help me out in adapting your script to have some additional functionality? I am interested in creating a fixed number of accounts, modifying all of them with a preset NAME and PASSWORD and then, when I need, to delete all of them.
For example: create account A > modify account A to have a specific name/password > (when needed) delete account A.
Unfortunately I can't seem to understand how to save the ID I receive when I first create the account (I see it in the console but can't find a proper way to extract it) and then, based on that ID, to change the account name and password. I know this script is old but it still works without any issue so far. I am just not that technical :(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to install cURL previously.