我遇到了有關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。謝謝。 –