Skip to content

Instantly share code, notes, and snippets.

@marciok
Last active November 24, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marciok/c607444c2bfa4508984b5276bb77d445 to your computer and use it in GitHub Desktop.
Save marciok/c607444c2bfa4508984b5276bb77d445 to your computer and use it in GitHub Desktop.
import base64
import requests
### readme
### id_number key in dictionary must include a well-formed cpf
### request smaller than 2MB
def encode_file(file_):
v_ = open(file_, 'rb')
v_read = v_.read()
v_64_encode = base64.encodestring(v_read)
with open(file_[:file_.index(".")]+".txt", "wb") as text_file:
text_file.write(v_64_encode)
def load_file(file_):
f_ = open(file_, 'rb')
f = f_.read()
return f
for f_ in ['video.mp4','image_front.jpg','image_back.jpg']:
encode_file(f_)
video, i_front,i_back = load_file('video.txt'), load_file('i_front.txt'), load_file('i_back.txt')
key = 'api_XADHcdMRDLfwO2Q1VQl9O9ztv2rpkglC'
dict_={'api_key': key,'first_name': 'João','last_name': 'Gomes',
'date_of_birth':'1999-08-23','email':'joao@gomes.net',
'id_number':'67671223786','company':'maryos',
'id_image_front':i_front,'id_image_back':i_back,
'video':video}
r = requests.post('https://api.test.identidata.io/v1/register', json=dict_)
##$ if you want to get the status code
print(r.status_code)
### if you want details if the returned status code is 400
print(r.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment