我遇到了有关Facebook Workplace的Account Management API的问题。我所要做的就是构建一个快速简便的员工目录,抓住我们所有的活跃用户,并吐出他们的名字,头衔,部门和照片。问题是,返回的数据似乎不符合上面链接中所示的Facebook核心架构。一些架构数据会回来,但从来没有照片,无论我怎么尝试。Facebook工作场所帐户管理API不返回照片
private function getEmployees()
{
$done = false;
$current_index = 1;
$current_page = 1;
$results = [];
while(!$done) {
$res = $this->client->request(
'GET',
'https://www.facebook.com/company/XXXXXXXXX/scim/Users?count=100&startIndex=' . $current_index,
[
'headers' => ['Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $this->token
]
]
);
$decoded = json_decode($res->getBody());
$total = $decoded->totalResults;
$perPage = $decoded->itemsPerPage;
if (isset($decoded->Resources)) {
$results = array_merge($results, $decoded->Resources);
if (($current_page * $perPage) >= $total) {
$done = true;
} else {
$current_page++;
$current_index += $perPage;
}
} else {
$done = true;
}
}
return $results;
}
哪还给:
object(stdClass)[392]
public 'schemas' =>
array (size=3)
0 => string 'urn:scim:schemas:core:1.0' (length=25)
1 => string 'urn:scim:schemas:extension:enterprise:1.0' (length=41)
2 => string 'urn:scim:schemas:extension:facebook:starttermdates:1.0' (length=54)
public 'id' => int 10001156699923
public 'userName' => string '[email protected]' (length=21)
public 'name' =>
object(stdClass)[393]
public 'formatted' => string 'Nick P' (length=11)
public 'title' => string 'Lead PHP Engineer' (length=17)
public 'active' => boolean true
public 'phoneNumbers' =>
array (size=1)
0 =>
object(stdClass)[394]
public 'primary' => boolean true
public 'type' => string 'work' (length=4)
public 'value' => string '+1631123456' (length=12)
public 'addresses' =>
array (size=1)
0 =>
object(stdClass)[395]
public 'type' => string 'attributes' (length=10)
public 'formatted' => string 'Manhattan' (length=9)
public 'primary' => boolean true
public 'urn:scim:schemas:extension:enterprise:1.0' =>
object(stdClass)[396]
public 'department' => string 'IT' (length=2)
public 'manager' =>
object(stdClass)[397]
public 'managerId' => int 100011017901494
public 'urn:scim:schemas:extension:facebook:starttermdates:1.0' =>
object(stdClass)[398]
public 'startDate' => int 0
public 'termDate' => int 0
所以你可以看到,它返回等领域是“核心”架构的一部分,但缺少“照片”阵列等。我认为这可能是因为用户没有任何照片,但几乎所有人都有个人资料照片,许多人有更多。我试图获得他们的用户信息,但遇到同样的结果,没有照片。
有人试过类似的东西吗?非常感谢任何帮助,这对我们来说是一个障碍。
感谢
我的印象是我不能使用常规的图形API的工作场所下?我只需要我们所有员工的名单,包括他们的姓名,职位,电子邮件,照片,而不是深度信息。另一个问题是Graph API需要使用OAuth2进行更加严格的认证流程,每次都必须由某人授权,或者使用长期令牌3个月。 SCIM在实际请求中只需要一个密钥。 如果Graph可用于Workplace并且是唯一的方法,我会切换。但文件说,数据应该回来与SCIM,所以我宁愿这一点。 –
此解决方案工作。我能够获得所有我想要的数据,而无需使用OAuth2。谢谢。 –