如何在 PHP 中验证 FB Workplace Account Management API?

How to authenticate FB Workplace Account Management API in PHP?

如何在 PHP 中验证 FB Workplace Account Management API?

他们没有在文档中提供太多细节,但这里仍然是文档的 link。(https://developers.facebook.com/docs/workplace/authentication/password)

这是我为获得身份验证而编写的代码,以便我可以获得 users.Though 的列表我想稍后添加和删除它们,这只能通过账户管理来完成 API 而不是图表 API.

代码:

$username='adnan@outsourcewebdev.com';

$password='P3YPFTluXc18'; 

//Its a trial acc username & pass. You can use to test it.

$URL='https://work-48884897.facebook.com/work/login';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,$URL);

curl_setopt($ch, CURLOPT_TIMEOUT, 30); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

$result=curl_exec ($ch);

print_r($result); 

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);  

echo $status_code; //get status code

curl_close ($ch);

帐户管理 API 与其他 Facebook API 一样,需要访问令牌,而不是 username/password 组合。

https://developers.facebook.com/docs/workplace/account-management/api

The Workplace Account Management API will only process requests that include a valid access token, which you must send with your API invocations as an authorization header.

您引用的文档只是解释了用户可以通过不止一种方式向 Facebook 网站 进行身份验证 - 通过 username/password 一个 SSO。