diff options
author | clarkzjw <[email protected]> | 2023-02-21 01:43:49 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-21 01:43:49 -0800 |
commit | 92c0139e067a7f40ef686714f6edaa8bb8970db7 (patch) | |
tree | 78d9eee925102930fff52d22a2f5c0d5824df4d4 /foursquare | |
parent | 88ad58c3d3412162ffdeb96f49b789e7976cad07 (diff) | |
parent | 1046a4dd835468ee4855d70ca0a5e6dc6f79cb32 (diff) | |
download | swarm2fediverse-92c0139e067a7f40ef686714f6edaa8bb8970db7.tar.gz |
Merge branch 'feature/poi_photo'
allow users to upload up to 4 photos when checking in
Diffstat (limited to 'foursquare')
-rw-r--r-- | foursquare/poi.py (renamed from foursquare/query_poi.py) | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/foursquare/query_poi.py b/foursquare/poi.py index e2d5625..722dbb7 100644 --- a/foursquare/query_poi.py +++ b/foursquare/poi.py | |||
@@ -6,17 +6,18 @@ from config import FSQ_API_KEY | |||
6 | from dbstore.dbm_store import store_loc | 6 | from dbstore.dbm_store import store_loc |
7 | 7 | ||
8 | POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}" | 8 | POI_API_ENDPOINT = "https://api.foursquare.com/v3/places/nearby?ll={}%2C{}" |
9 | POI_PHOTO_ENDPOINT = "https://api.foursquare.com/v3/places/{}/photos?sort=POPULAR&limit=10" | ||
9 | OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" | 10 | OSM_ENDPOINT = "https://www.openstreetmap.org/?mlat={}&mlon={}&zoom=15&layers=M" |
11 | headers = { | ||
12 | "accept": "application/json", | ||
13 | "Authorization": FSQ_API_KEY | ||
14 | } | ||
10 | 15 | ||
11 | 16 | ||
12 | def query_poi(latitude, longitude): | 17 | def query_poi(latitude, longitude): |
13 | locations = list() | 18 | locations = list() |
14 | 19 | ||
15 | url = POI_API_ENDPOINT.format(latitude, longitude) | 20 | url = POI_API_ENDPOINT.format(latitude, longitude) |
16 | headers = { | ||
17 | "accept": "application/json", | ||
18 | "Authorization": FSQ_API_KEY | ||
19 | } | ||
20 | 21 | ||
21 | response = requests.get(url, headers=headers) | 22 | response = requests.get(url, headers=headers) |
22 | 23 | ||
@@ -34,3 +35,19 @@ def query_poi(latitude, longitude): | |||
34 | store_loc(loc) | 35 | store_loc(loc) |
35 | 36 | ||
36 | return locations | 37 | return locations |
38 | |||
39 | |||
40 | def get_poi_top_photo(fsq_id): | ||
41 | url = POI_PHOTO_ENDPOINT.format(fsq_id) | ||
42 | response = requests.get(url, headers=headers) | ||
43 | |||
44 | poi_photo_urls = [] | ||
45 | for poi in json.loads(response.text): | ||
46 | prefix = poi["prefix"] | ||
47 | suffix = poi["suffix"] | ||
48 | poi_photo_urls.append(prefix + "original" + suffix) | ||
49 | |||
50 | if len(poi_photo_urls) == 0: | ||
51 | return None | ||
52 | |||
53 | return poi_photo_urls[0] | ||