Created
March 14, 2014 23:47
-
-
Save edwindotcom/9559424 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import urllib2 | |
import urllib | |
import urlparse | |
import json | |
import sys | |
if len(sys.argv) < 2: | |
sys.stderr.write('Usage: python verifyAcct.py email ') | |
sys.exit(1) | |
email_url = 'http://restmail.net/mail/%s' % sys.argv[1] | |
def get_verify_url(url): | |
verify_url = urllib2.urlopen(url).read() | |
json_str = json.loads(verify_url) | |
return json_str[-1]['headers']['x-link'] | |
def load_verify_url(url): | |
qs = urlparse.urlparse(verify_url).query | |
qs_dict = urlparse.parse_qs(qs) | |
data = urllib.urlencode({"uid":qs_dict['uid'][0], "code":qs_dict['code'][0]}) | |
req = urllib2.Request("https://api.accounts.firefox.com/v1/recovery_email/verify_code", data) | |
return urllib2.urlopen(req) | |
verify_url = get_verify_url(email_url) | |
print verify_url | |
resp = load_verify_url(verify_url) | |
print resp.code | |
if resp.code == 200: | |
print 'Verified Acct' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment