自 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
要求,然後查看 access_status
欄位的 PENDING
。
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
,則無法授予資產存取權限。
例如,若要授予某用戶對廣告帳號的存取權限,以使用 [
ADVERTISE,
ANALYZE]
任務,請使用下列 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>"
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.
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" }
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" }
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" } } ] }
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" } ] }
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" } ] }