Create instagram_adapter.py
Browse files
services/social_adapters/instagram_adapter.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import asyncio
|
| 3 |
+
|
| 4 |
+
# Instagram Graph API の実装はここに。
|
| 5 |
+
# ここではトークン未設定時は疑似成功、設定時は TODO: 実装ポイント。
|
| 6 |
+
|
| 7 |
+
async def search_recent_instagram(keywords: list[str], limit: int = 20):
|
| 8 |
+
token = os.getenv("IG_ACCESS_TOKEN")
|
| 9 |
+
if not token:
|
| 10 |
+
return [{"platform": "instagram", "text": f"IG疑似: {kw} の話題", "author": "ig_user", "url": "https://instagram.com/example"} for kw in keywords][:limit]
|
| 11 |
+
# TODO: Hashtag Search / Business Discovery など
|
| 12 |
+
await asyncio.sleep(0.1)
|
| 13 |
+
return [{"platform":"instagram", "text":"[TODO] real IG search result", "author":"real", "url":"https://instagram.com"}]
|
| 14 |
+
|
| 15 |
+
async def post_to_instagram(text: str, image_prompt: str | None) -> bool:
|
| 16 |
+
token = os.getenv("IG_ACCESS_TOKEN")
|
| 17 |
+
if not token:
|
| 18 |
+
await asyncio.sleep(0.1)
|
| 19 |
+
return True
|
| 20 |
+
# TODO: media container 作成→publish
|
| 21 |
+
await asyncio.sleep(0.1)
|
| 22 |
+
return True
|