Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parse_contact_data(json_data, results, THINGAMAJIG, API_KEY):
- params = { "access_token": API_KEY }
- for d in json_data['results']:
- if results != []:
- results.append([d['person_id'], d['note'], d['path_id'], d['step_id'], d['created_at']])
- if json_data['next']:
- r = requests.get(endpoint(json_data['next'], THINGAMAJIG), params=params)
- next_json_data = json.loads(r.text)
- parse_contact_data(next_json_data,results, THINGAMAJIG, API_KEY)
- return results
- def get_contact_notes(THINGAMAJIG, API_KEY, ids_of_those_tagged):
- results = []
- for each in ids_of_those_tagged:
- try:
- url = 'https://'+THINGAMAJIG+'.THINGAMAJIGbuilder.com/api/v1/contacts?person_id=' + str(each)
- contact_response = requests.get(url, params=params)
- #if contact_response.text != []
- print(contact_response.json())
- json_data = json.loads(contact_response.text)
- full_result = parse_contact_data(json_data, results, THINGAMAJIG, API_KEY)
- except requests.exceptions.ConnectionError:
- print("Error reaching THINGAMAJIGbuilder")
- print(results)
- return results
- contact_notes = get_contact_notes(THINGAMAJIG, API_KEY, ids_of_those_tagged)
- print("done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement