Created
June 16, 2012 04:07
-
-
Save mmohiudd/2939872 to your computer and use it in GitHub Desktop.
change Facebook test user password
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
#!/usr/bin/env python | |
''' | |
Change Facebook test users password | |
''' | |
import urllib, urllib2, json | |
# makes a batch call to facebook | |
# access_token : facebook access token | |
# batch_data : dictionary of batch data | |
def batch_call(access_token, batch_data): | |
end_point = 'https://graph.facebook.com' | |
data = urllib.urlencode({'access_token': access_token, 'batch': json.dumps(batch_data) }) # create post data | |
try: | |
url = urllib2.urlopen(end_point, data) | |
response = url.read() | |
url.close() | |
return response | |
except urllib2.HTTPError, e: | |
# show error | |
print e | |
print e.read() | |
return None # will return None by default | |
config = {'app_id': '<app id>', 'app_secret': '< app secret>'} | |
config['access_token'] = config['app_id'] + "|" + config['app_secret'] # generic app access token | |
batch_data = [ | |
{ # get all test users for this application | |
'method' : "GET", | |
'relative_url' : config['app_id'] + "/accounts/test-users", | |
}, | |
] | |
response = json.loads(batch_call(config['access_token'], batch_data)) | |
data = json.loads(response[0]['body'])['data'] | |
batch_data = [] # recycle electrons | |
for user in data: | |
print user['id'] | |
batch_data.append({ | |
'method' : "POST", | |
'relative_url' : user['id'] + "/?password=123123", | |
}) | |
batch_call(config['access_token'], batch_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment