Created
August 27, 2013 01:25
-
-
Save guilhermebr/6348686 to your computer and use it in GitHub Desktop.
Codigo para sorteio de entradas no evento http://www.joincommunity.com.br
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
''' | |
Codigo para sorteio de entradas no evento http://www.joincommunity.com.br | |
@guilhermebr - Guilherme Rezende <guilhermebr@gmail.com> | |
''' | |
import urllib | |
import json | |
from random import shuffle, choice | |
#token temporario(1h) obtido em https://developers.facebook.com/tools/explorer | |
token = '' | |
#url com id do post no grupo. | |
url = 'https://graph.facebook.com/217798571657785_415898611847779/likes?limit=100&access_token=' | |
resp = urllib.urlopen(url + token).read() | |
data = json.loads(resp.decode('utf-8')) | |
#cast para lista | |
people = list(data['data']) | |
#embaralhar lista | |
shuffle(people) | |
#for person in people : | |
# print person | |
while True: | |
print 'Pessoas Participando: ' + str(len(people)) | |
#escolhe uma pessoa na lista | |
sorteado = choice(people) | |
#obter mais dados do sorteado | |
url_sorteado = 'https://graph.facebook.com/%s/?access_token=' % sorteado['id'] | |
resp = urllib.urlopen(url_sorteado + token).read() | |
data = json.loads(resp.decode('utf-8')) | |
print ''' | |
--Sorteado-- | |
Nome: %s | |
Perfil: %s | |
''' % (data['name'], data['link']) | |
continua = raw_input('Sortear denovo? [s/N]') | |
if continua.upper() == 'S': | |
people.remove(sorteado) | |
else: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment