我对Facebook Workplace的Account Management API存在问题。我所要做的就是建立一个快速简便的员工目录,抓住我们所有的活跃用户并吐出他们的名字,头衔,部门和照片。问题是,返回的数据似乎与Facebook Core Schema不匹配,如上面的链接所示。一些架构数据回来了,但从来没有照片,无论我似乎尝试什么。
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 'np@lt.com' (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
正如您所看到的,它返回属于“核心”架构的其他字段,但缺少“照片”数组和其他字段。我认为这可能是因为用户没有任何照片,但几乎所有照片都有,而且很多都有。我尝试专门获取他们的用户信息,但遇到了相同的结果,没有照片。
有人试过类似的东西吗?任何帮助非常感谢,这对我们来说是一个障碍。
由于
答案 0 :(得分:2)
要获取个人资料信息,请不要使用SCIM,而应使用图表API https://graph.facebook.com/community/members将列出所有成员
和https://graph.facebook.com/[email]您的某个成员将获得所有信息。
之后,您必须使用字段参数设置要获取的参数。
在我们的实现中,我们从此请求中获取了整个数据
https://graph.facebook.com/XXXX/members?fields=email,picture.type(large),link,title,first_name,last_name,department,updated_time,managers {电子邮件}&安培;限= 500