Skip to content

Instantly share code, notes, and snippets.

@scari
Last active September 22, 2015 14:19
Show Gist options
  • Save scari/6f11ce04c51ba9e1d889 to your computer and use it in GitHub Desktop.
Save scari/6f11ce04c51ba9e1d889 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import json
import requests
import numpy.random
# https://developers.facebook.com/tools/explorer
# I've used v2.3 and you need `read_stream` permission to use this script.
from local_setting import FB_ACCESS_TOKEN
POST_ID = '10206524181161780' # Use your one. This is mine XD
REQ_URL = 'https://graph.facebook.com/v2.3/{}/sharedposts?access_token={}'.format(POST_ID, FB_ACCESS_TOKEN)
resp = json.loads(requests.get(REQ_URL).text)
shared_list = [e.get('from')['name'] for e in resp['data'] if 'from' in e]
winners = numpy.random.choice(shared_list, 2, replace=False)
print(winners)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment