Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -173,7 +173,7 @@ async def ig_post_detail(post_id: Optional[str] = None, url: Optional[str] = Non
|
|
173 |
|
174 |
|
175 |
@app.get("/facebook_post_details")
|
176 |
-
async def fb_post_detail(username: Optional[str] = None, post_id: Optional[str] = None, url: Optional[str] = None):
|
177 |
if not url:
|
178 |
url = f"https://www.facebook.com/{username}/posts/{post_id}"
|
179 |
else:
|
@@ -235,6 +235,16 @@ async def fb_post_detail(username: Optional[str] = None, post_id: Optional[str]
|
|
235 |
|
236 |
name = soup.find("meta", {"property": "og:title"}).get("content")
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
return {
|
240 |
"insights": {
|
@@ -247,7 +257,8 @@ async def fb_post_detail(username: Optional[str] = None, post_id: Optional[str]
|
|
247 |
"description": desc,
|
248 |
"username": username,
|
249 |
"name": name,
|
250 |
-
"date":
|
|
|
251 |
}
|
252 |
|
253 |
|
|
|
173 |
|
174 |
|
175 |
@app.get("/facebook_post_details")
|
176 |
+
async def fb_post_detail(username: Optional[str] = None, post_id: Optional[str] = None, url: Optional[str] = None, api_access_key: Optional[str] = None):
|
177 |
if not url:
|
178 |
url = f"https://www.facebook.com/{username}/posts/{post_id}"
|
179 |
else:
|
|
|
235 |
|
236 |
name = soup.find("meta", {"property": "og:title"}).get("content")
|
237 |
|
238 |
+
date = None
|
239 |
+
|
240 |
+
if api_access_key:
|
241 |
+
if not post_id:
|
242 |
+
post_id = url.split("/")[-1]
|
243 |
+
try:
|
244 |
+
post_details = requests.get(f"1066512588151225_{post_id}?access_token={api_access_key}&fields=place,shares,targeting,updated_time,created_time,description,child_attachments,caption,event,message,message_tags,story,status_type,source,coordinates,backdated_time,story_tags,scheduled_publish_time,properties,attachments").json()
|
245 |
+
date = post_details.get("updated_date")
|
246 |
+
except Exception as e:
|
247 |
+
print(e)
|
248 |
|
249 |
return {
|
250 |
"insights": {
|
|
|
257 |
"description": desc,
|
258 |
"username": username,
|
259 |
"name": name,
|
260 |
+
"date": date,
|
261 |
+
"details":post_details
|
262 |
}
|
263 |
|
264 |
|