-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsta_api_client.py
More file actions
43 lines (32 loc) · 1023 Bytes
/
Copy pathinsta_api_client.py
File metadata and controls
43 lines (32 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import requests
import json
from pymongo import MongoClient
import time
headers = {'Content-Type': 'application/json'}
api_endpoint='http://localhost:5000/api/v1.0'
def api_post(endpoint,payload=None):
headers = {
'Content-Type': 'application/json'
}
response = requests.post('{}{}'.format(api_endpoint, endpoint), data=json.dumps(payload),headers=headers)
return response
def api_get(endpoint, params=None):
headers = {
'Content-Type': 'application/json'
}
response = requests.get('{}{}'.format(api_endpoint, endpoint), params=params,headers=headers)
return response
def test_instapi_api(user):
response = api_get('/instapi/'+user)
if response.status_code == 200:
return json.loads(response.content)
else:
return None
def test_getter(j_id):
response = api_get('/instapi/'+str(j_id))
return response.content
def main():
job_id = test_instapi_api(str('insta_username'))
print job_id
if __name__ == '__main__':
main()