Created
November 15, 2017 12:03
-
-
Save odrianoaliveira/d264d439959197cc2eaae6b09f20ccfd 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
""" | |
File name: main.py | |
Author: adriano | |
Date created: 10/11/17 | |
""" | |
import json | |
import requests | |
from requests.auth import HTTPBasicAuth | |
__HOST = "http://apisdigitais.interno:8765" | |
__PATH = "/api/campaignapi/v1/campaign/1/enrollevent" | |
__URL = __HOST + __PATH | |
headers = {'content-type': 'application/json'} | |
with open("msisdns.txt") as f: | |
for line in f: | |
msisdn = line.rstrip('\n') | |
payload = {"msisdn": msisdn, "os": "Android"} | |
r = requests.post(__URL, auth=HTTPBasicAuth('user', 'password'), data=json.dumps(payload), headers=headers) | |
if r.status_code == 201: | |
print("msisdn:" + msisdn + " # status=OK") | |
else: | |
print("msisdn:" + msisdn + " # status=NOK") | |
print(r.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment