diff --git a/.gitignore b/.gitignore index e920b94..2950b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ build/ **creds.json -BeReal_dl/ \ No newline at end of file +BeReal_dl/ +venv/ \ No newline at end of file diff --git a/BeReal/__init__.py b/BeReal/__init__.py index f85a3f8..927ebd4 100644 --- a/BeReal/__init__.py +++ b/BeReal/__init__.py @@ -57,4 +57,8 @@ def get_feed(self): def get_fof(self): fof_feed = fof.get_fof_feed(self.id_token) - return fof_feed \ No newline at end of file + return fof_feed + + def search(self, query:str): + results = profile.search_profile(self.id_token, query) + return results \ No newline at end of file diff --git a/BeReal/profile.py b/BeReal/profile.py index 34262e4..a8f1a31 100644 --- a/BeReal/profile.py +++ b/BeReal/profile.py @@ -5,10 +5,16 @@ from . import classes def get_profile(auth_token:str) -> classes.Me: - res = requests.get(API_URL + "/person/me", headers={"Authorization": "Bearer " + auth_token}) + res = requests.get(API_URL + "/person/me", headers={"Authorization": "Bearer " + auth_token} | HEADERS) if res.status_code == 401: raise Exception("Invalid token. Has it expired?") - friends_res = requests.get(API_URL + "/relationships/friends", headers={"Authorization": "Bearer " + auth_token}) + friends_res = requests.get(API_URL + "/relationships/friends", headers={"Authorization": "Bearer " + auth_token} | HEADERS) if res.status_code == 401: raise Exception("Invalid token. Has it expired?") return classes.Me(res.json(), friends_res.json()['data']) + +def search_profile(auth_token:str, query:str) -> list[classes.Person]: + res = requests.get(API_URL + f"/search/profile", headers={"Authorization": "Bearer " + auth_token} | HEADERS, params={"query": query}) + if res.status_code == 401: + raise Exception("Invalid token. Has it expired?") + print(res.text) diff --git a/Example/search.py b/Example/search.py new file mode 100644 index 0000000..cfe9bfc --- /dev/null +++ b/Example/search.py @@ -0,0 +1,12 @@ +import BeReal +import json +import sys + +client = BeReal.BeReal("") + +f = open("creds.json", "r") +client.resume_session(json.loads(f.read())) +f.close() + +me = client.me() +client.search("starnumber") \ No newline at end of file