forked from jatin-dot-py/zomato-intelligence
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrent_user.py
More file actions
38 lines (32 loc) · 1.14 KB
/
current_user.py
File metadata and controls
38 lines (32 loc) · 1.14 KB
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
import requests
def get_zomato_user_info(access_token, proxies=None):
"""
Fetches the user info from Zomato API.
"""
url = "https://api.zomato.com/gw/user/info"
headers = {
"Accept": "image/webp",
"Accept-Encoding": "gzip, deflate, br",
"Connection": "keep-alive",
"Host": "api.zomato.com",
"X-Zomato-Access-Token": access_token,
"X-Zomato-API-Key": "7749b19667964b87a3efc739e254ada2",
"X-Zomato-App-Version": "931",
"X-Zomato-App-Version-Code": "1710019310",
"X-Zomato-Client-Id": "5276d7f1-910b-4243-92ea-d27e758ad02b",
"X-Zomato-Is-Metric": "true",
"X-Zomato-UUID": "b2691abb-5aac-48a5-9f0e-750349080dcb"
}
try:
response = requests.get(url, headers=headers, proxies=proxies, verify=True if not proxies else False)
response.raise_for_status()
return {
"success": True,
"status_code": response.status_code,
"data": response.json()
}
except requests.exceptions.RequestException as e:
return {
"success": False,
"error": str(e)
}