/api/v4/connected-accounts/connect-facebook連結 Facebook 帳號
傳回 OAuth URL,將 Facebook 粉絲專頁帳號連結至您的 Listings API 帳戶。
參數
請求主體
| 名稱 | 類型 | 必填 | 說明 |
|---|---|---|---|
| input | object | 必填 | Wrapper object. The entire request body must be nested under `input`. |
| input.successUrl | string | 必填 | URL the user is redirected to after they successfully authorize Facebook. Must be an absolute https URL you control. |
| input.errorUrl | string | 必填 | URL the user is redirected to if they cancel or the authorization fails. Must be an absolute https URL you control. |
請求範例
可直接貼上的請求主體。請將預留位置 ID 與值換成您自己的。
{ "input": { "successUrl": "https://listingsapi.com/docs/api/connected-accounts-trigger-matches", "errorUrl": "https://listingsapi.com/docs/api/connected-accounts-connect-facebook" }}回應
200OAuth URL generated successfully. Redirect the user to `url` to begin the Facebook authorization flow. The `url` shown is a placeholder; send the user to the `url` returned in your own response.
{ "data": { "bulkConnectLinkForFacebook": { "errors": null, "success": true, "url": "https://connect.example.com/oauth?token=8f3c1d92-..." } }}400Bad request, the body was not wrapped in `input`, or `successUrl`/`errorUrl` was omitted (error message: `Variable "$input" of required type "FacebookOauthBulkInput!" was not provided`).
401Unauthenticated, missing or invalid API key.
產生短效的 OAuth URL,使用者可前往該 URL,授權 Listings API 批次管理其 Facebook 粉絲專頁。請將使用者重新導向至傳回的 url;在此流程中,使用者會檢閱並接受 Facebook 的條款,並授予 Listings API 所需的粉絲專頁管理權限。此連結的有效期限為 24 小時。
請求格式。 請求主體必須包裝在 input 物件中,並包含 2 個必填欄位:successUrl 和 errorUrl。這些是使用者完成(或放棄)Facebook 授權流程後返回的絕對 https URL;請傳入您自己應用程式中的端點,以便在成功時繼續初始設定流程,並在發生錯誤時提供重試選項。此請求沒有 accountId 欄位,連結一律僅適用於擁有該 API 金鑰的帳戶,而傳送 accountId(或未包裝的扁平請求主體)會遭到拒絕,並傳回 HTTP 400。
此端點是 connect-google 端點的 Facebook 對應版本,也是批次連結工作流程的第一步。授權完成後,該帳號會出現在 GET /connected-accounts 中,並附有用於配對與同步的 connectedAccountId。
使用案例:設定客戶的 Facebook 粉絲專頁。 客戶授予 Facebook 存取權後,請將其重新導向至傳回的 url。客戶完成後,請執行 POST /connected-accounts/trigger-matches,使用 GET /connected-accounts/{connectedAccountId}/connection-suggestions 檢視結果,並透過 POST /connected-accounts/confirm-matches 確認配對,讓 Facebook 粉絲專頁資料開始與配對的 Listings API 地點同步。
使用案例:拒絕授予權限後重新授權。 如果使用者略過必要的 Facebook 權限,該連線便無法同步。請重新產生連結,並請使用者重新授權,授予所有權限。
若要連結 Google,請使用 connect-google 端點。success: true 且 url 不為 null,表示連結已產生;只有在產生失敗時,errors 才會填入值。
curl -X POST 'https://listingsapi.com/api/v4/connected-accounts/connect-facebook' \ -H "Authorization: API $LISTINGSAPI_KEY" \ -H 'Content-Type: application/json' \ -d '{ "input": { "successUrl": "https://listingsapi.com/docs/api/connected-accounts-trigger-matches", "errorUrl": "https://listingsapi.com/docs/api/connected-accounts-connect-facebook" } }'