POST/api/v4/connected-accounts/connect-facebook

连接 Facebook 账号

返回一个 OAuth URL,用于将 Facebook Pages 账号关联到您的 Listings API 账户。

需要 API 密钥。请求头格式和密钥轮换请参阅身份验证。

参数

请求体

名称类型必填描述
inputobject必填Wrapper object. The entire request body must be nested under `input`.
input.successUrlstring必填URL the user is redirected to after they successfully authorize Facebook. Must be an absolute https URL you control.
input.errorUrlstring必填URL the user is redirected to if they cancel or the authorization fails. Must be an absolute https URL you control.

请求示例

可直接粘贴的请求体。请将占位 ID 和值替换为您自己的。

Request body
{  "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.
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。这两个字段是绝对 https URL,用户完成(或放弃)Facebook 授权流程后将返回这些 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。

Request
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"    }  }'