企业对企业的功能

自 2021 年 6 月 8 日起,对以下端点的访问受到限制。如果应用不具备访问权限,会收到错误消息。

请求资产的访问权限

商务管理平台可以请求其他商务管理平台拥有的广告账户或公共主页的访问权限。该商务管理平台必须在请求中指定想要分配的任务。

如要向企业分配公共主页的访问权限,需要具备公共主页口令;例如:

curl 
  -F "business=<BUSINESS_ID>"
  -F "permitted_tasks=['MODERATE', 'ADVERTISE', 'ANALYZE']"   
  "https://graph.facebook.com/<API_VERSION>/<PAGE_ID>/agencies?access_token=<ACCESS_TOKEN>"

如要请求获取 AGENCY 权限,您必须在请求中提供 permitted_tasks。您只能向您打算批准的商务管理平台发送资产访问请求,并且对方必须已知道您的企业。

例如,如果企业需要 adaccount_id 的访问权限,并且需要为其工作人员分配 ['ADVERTISE', 'ANALYZE'] 任务,应该执行以下 POST 调用:

curl \
  -F "adaccount_id=act_<AD_ACCOUNT_ID>" \
  -F "permitted_tasks=['ADVERTISE','ANALYZE']" \
  "https://graph.facebook.com/<API_VERSION>/<BUSINESS_ID>/client_ad_accounts?access_token=<ACCESS_TOKEN>"

公共主页情况类似,对于不属于特定企业的公共主页,如果您希望分配该公共主页的 ['ADVERTISE', 'ANALYZE'] 任务,请执行以下调用:

curl \
  -F "page_id=<PAGE_ID>" \
  -F "permitted_tasks=['ADVERTISE','ANALYZE']" \
  "https://graph.facebook.com/<API_VERSION>/<BUSINESS_ID>/client_pages?access_token=<ACCESS_TOKEN>" 

这些调用将向广告账户或公共主页的相应管理员发出通知,要求他们接受访问请求。相应管理员将在广告管理工具或公共主页管理工具中看到这类通知。他们还可以在用户界面接受这些请求。如果您想通过 API 来查看未回复的请求,请执行 GET 请求,并查看值为 PENDINGaccess_status 字段。

curl "https://graph.facebook.com/<API_VERSION>/<BUSINESS_ID>/clients?access_token=<ACCESS_TOKEN>"

响应:

"data": [
 {
    "name": "Random Page", 
    "page_permissions": [
    {
    "id": "1900952844321", 
    "permitted_tasks": [
        'MANAGE',
        'CREATE_CONTENT', 
        'MODERATE',  
        'ADVERTISE', 
        'ANALYZE',
    ], 
    "access_status": "CLIENT_RESPONSE_PENDING", 
    "access_requested_time": "2014-01-07T23:26:09+0000", 
    "access_updated_time": "2014-01-07T23:26:09+0000"
    }
    ], 
    "id": "190137931178903"
 },

向另一商务管理平台授予资产访问权限

这也称为将代理商添加到您的企业中

如要接受其他商务管理平台针对您拥有的某个资产发送的访问请求,或者说向其他商务管理平台授予您拥有的某个资产的访问权限,您必须指定企业及该企业应该有权访问的任务清单。

如果用于执行 API 调用的访问口令所属的用户或系统用户有权通过某个企业访问请求的资产,则仅在该企业是此资产的 OWNER 时,才能授予该资产的访问权限。如果您仅是资产的 AGENCY,则无法授予该资产的访问权限。

例如,如要向特定企业授予某个广告账户的访问权限,并指定该企业应该有权访问 [ADVERTISEANALYZE] 任务,请执行以下 POST 请求:

curl \
  -F "business=<BUSINESS_ID>" \
  -F "permitted_tasks=['ADVERTISE', 'ANALYZE']" \
  "https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/agencies?access_token=<ACCESS_TOKEN>"

如要向特定企业授予您公共主页的访问权限,并指定该企业应该有权访问 [ADVERTISE][MODERATE][ANALYZE] 任务,请执行以下请求:

curl \
  -F "business=<BUSINESS_ID>" \
  -F "permitted_tasks=['MODERATE', 'ADVERTISE', 'ANALYZE']" \
  "https://graph.facebook.com/<API_VERSION>/<PAGE_ID>/agencies?access_token=<ACCESS_TOKEN>"

如要授予广告账户的访问权限,为安全起见,有时需要另一位企业管理员进行审核。前往 https://business.facebook.com/settings/requests/admin_reviews,可批准此项审核。在这种情况下,响应中将包含一个额外的字段,表示请求需要接受审核。

{
  "success": true,
  "requires_admin_approval": true
}

公共主页管理员还可以在 facebook.com 中“公共主页设置”的 Manage Admin Roles 选项卡接受代理商的访问请求。

移除资产的访问权限

这也称为将代理商从您的企业中移除。如要从您的广告账户中移除某个商务管理平台的访问权限,请执行以下调用:

curl \
  -X DELETE \
  -F "business=<BUSINESS_ID>" \
  "https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/agencies?access_token=<ACCESS_TOKEN>"

同样,如要从您的公共主页中移除某个企业的访问权限,请执行以下调用:

curl \
  -X DELETE \
  -F "business=<BUSINESS_ID>" \
  "https://graph.facebook.com/<API_VERSION>/<PAGE_ID>/agencies?access_token=<ACCESS_TOKEN>"

查看代理商的访问权限

如要查看有权访问您广告账户的所有企业,请执行以下 GET 调用:

curl "https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/agencies?access_token=<ACCESS_TOKEN>"

如要查看有权访问您公共主页的所有企业,请执行以下调用:

curl "https://graph.facebook.com/<API_VERSION>/<PAGE_ID>/agencies?access_token=<ACCESS_TOKEN>"

如要查看有权访问您业务资产的所有企业,请执行以下调用:

curl "https://graph.facebook.com/<API_VERSION>/<BUSINESS_ID>/agencies?access_token=<ACCESS_TOKEN>"

查看客户的访问权限

如要查看已向您授予一个或多个广告账户或公共主页的访问权限的所有企业,请执行以下 GET 调用:

curl "https://graph.facebook.com/<API_VERSION>/<BUSINESS_ID>/clients?access_token=<ACCESS_TOKEN>"

Managing Your Relationship as an Ad Agency Acting on Behalf of Another Business

These APIs allow you to manage the relationship between your Ad Accounts and the businesses for which you are acting on behalf of (OBO). Creating these relationships allows you to access custom audiences for the business and use of the audience overlap tool.

View OBO Request Details

To view the details of an OBO request, make this GET request:

curl -G \
  -F "access_token=<ACCESS_TOKEN>" \
  "https://graph.facebook.com/<API_VERSION>/<OBO_REQUEST_ID>?fields=id,receiving_business,requesting_business,status,business_owned_object"

The response contains the details of the OBO request and looks like this:

{
  "id": "1111111111",
  "receiving_business": {
    "id": "2222222222",
    "name": "Example Business Name"
  },
  "requesting_business": {
    "id": "3333333333",
    "name": "Example Business Name"
  },
  "status": "IN_PROGRESS",
  "business_owned_object": "1111111111"
}

Delete OBO Request

To cancel a pending request to act OBO another business, make this DELETE request:

curl \
  -X DELETE \
  -F "access_token=<ACCESS_TOKEN>" \
  "https://graph.facebook.com/<API_VERSION>/<OBO_REQUEST_ID>"

The response, indicating success or failure, looks like this:

{
  "success": "true" 
}

View the Status of OBO Requests for an Ad Account

To view the status of requests to act OBO another business for an Ad account, make this GET request:

curl -G \
  -F "access_token=<ACCESS_TOKEN>" \
  "https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/onbehalf_requests?
    fields=id,status,receiving_business,requesting_business&status=<STATUS>"

The status parameter in the request must be APPROVE, DECLINE, or IN_PROGRESS.

The response contains an array with the OBO request objects for an Ad account matching the requested status.

Example response:

{
  "data": [
    {
      "id": "1111111111",
      "status": "IN_PROGRESS",
      "receiving_business": {
        "id": "2222222222",
        "name": "Example Business Name"
      },
      "requesting_business": {
        "id": "3333333333",
        "name": "Example Business Name"
      }
    }
  ]
}

View OBO Requests Received From Other Businesses

To view requests of IN_PROGRESS OBO requests sent to your business, make this GET request:

curl -G \
  -F "access_token=<ACCESS_TOKEN>" \
  "https://graph.facebook.com/<API_VERSION>/<BUSINESS_ID>/received_inprogress_onbehalf_requests"

The response contains the IN_PROGRESS OBO request IDs and looks like this:

{
  "data": [
    {
      "id": "1111111111"
    },
    {
      "id": "2222222222"
    },
    {
      "id": "3333333333"
    }
  ]
}

View Pending OBO Requests Sent by Your Business

To view OBO requests that were sent by your business that are still in the IN_PROGRESS state, make this GET request:

curl -G \
  -F "access_token=<ACCESS_TOKEN>" \
  "https://graph.facebook.com/<API_VERSION>/<BUSINESS_ID>/sent_inprogress_onbehalf_requests"

The response contains the IN_PROGRESS OBO request IDs and looks like this:

{
  "data": [
    {
      "id": "1111111111"
    },
    {
      "id": "2222222222"
    },
    {
      "id": "3333333333"
    }
  ]
}