透過特定關鍵字搜尋公開 Threads 影音內容,或按主題標籤搜尋。
Threads 關鍵字搜尋 API 需要適當的存取憑證和權限。測試時,您可以透過使用 Graph API 測試工具輕鬆產生憑證,並向您的應用程式授予權限。
threads_basic
:如要向所有 Threads API 端點發出任何呼叫,此為必要項目。threads_keyword_search
:如要向關鍵字搜尋端點發出 GET 呼叫,此為必要項目。如果您的應用程式尚未獲得 threads_keyword_search
權限,系統只會在已通過驗證用戶所擁有的帖子上執行搜尋。獲得批准後,公開帖子便可供搜尋。
如要按關鍵字搜尋公開 Threads 影音內容,請向 /keyword_search
端點發出 GET
要求,並在要求中加入要查詢的關鍵字。
名稱 | 說明 |
---|---|
字串 | 此為必要項目。 |
字串 | 此為選用項目。 值:
|
字串 | 此為選用項目。 值:
|
| 此為選用項目。 |
| 此為選用項目。 |
| 此為選用項目。 |
如要取得可用欄位的清單,請參閱影音內容文件。請注意:系統會排除且不會傳回擁有者欄位。
curl -s -X GET \ -F "q=<KEYWORD>" \ -F "search_type=TOP" \ -F "fields=id,text,media_type,permalink,timestamp,username,has_replies,is_quote_post,is_reply" \ -F "access_token=<THREADS_ACCESS_TOKEN>" \ "https://graph.threads.net/v1.0/keyword_search"
{ "data": [ { "id": "1234567890", "text": "First Thread", "media_type": "TEXT", "permalink": "https://www.threads.net/@threadsapitestuser/post/abcdefg", "timestamp": "2023-10-17T05:42:03+0000", "username": "threadsapitestuser", "has_replies": false, "is_quote_post": false, "is_reply": false } ] }
如要按主題標籤搜尋公開 Threads 影音內容,請向 /keyword_search
端點發出 GET
要求,並在要求中加入要查詢的關鍵字。如要搜尋主題標籤,您需要使用 search_mode
參數並將其值設為 TAG
。
curl -s -X GET \ -F "q=<TAG>" \ -F "search_mode=TAG" \ -F "search_type=TOP" \ -F "fields=id,text,media_type,permalink,timestamp,username,has_replies,is_quote_post,is_reply" \ -F "access_token=<THREADS_ACCESS_TOKEN>" \ "https://graph.threads.net/v1.0/keyword_search"
{ "data": [ { "id": "1234567890", "text": "First Thread", "media_type": "TEXT", "permalink": "https://www.threads.net/@threadsapitestuser/post/abcdefg", "timestamp": "2023-10-17T05:42:03+0000", "username": "threadsapitestuser", "has_replies": false, "is_quote_post": false, "is_reply": false } ] }
您可以向 /me
端點發出 GET
要求,並要求取得 recently_searched_keywords
欄位,以擷取目前已通過驗證用戶最近搜尋的關鍵字之清單。
curl -s -X GET \ -F "fields=recently_searched_keywords" \ -F "access_token=<THREADS_ACCESS_TOKEN>" \ "https://graph.threads.net/v1.0/me"
{ "id": "1234567890", "recently_searched_keywords": [ { "query": "some keyword", "timestamp": 1735707600000, }, { "query": "some other keyword", "timestamp": 1735707600000, } ] }