Skip to content

Instantly share code, notes, and snippets.

@denny0223
Created October 1, 2015 15:21
Show Gist options
  • Save denny0223/47895bbd2449a901dfa1 to your computer and use it in GitHub Desktop.
Save denny0223/47895bbd2449a901dfa1 to your computer and use it in GitHub Desktop.
FB message count ranking
token=''
res=$(curl -s "https://graph.facebook.com/v2.0/fql?access_token=$token&debug=all&format=json&method=get&pretty=0&q=SELECT%20viewer_id%2Crecipients%2Cmessage_count%20FROM%20thread%20WHERE%20folder_id%20%3D%200%20ORDER%20BY%20message_count%20DESC&suppress_http_code=1")
data=$(echo $res | jq '.data')
for i in $(seq 0 $(($(echo $data | jq '. | length') - 1)))
do
echo No. $((i + 1))
echo $data | jq ".[$i].message_count"
for fbid in $(echo $data | jq ".[$i].recipients[1:] | .[]")
do
fbid=$(echo $fbid | awk -F\" '{print $2}')
curl -s https://graph.facebook.com/$fbid?access_token=$token | jq '.name'
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment