facebook-graph-api - Facebook Workplace Account Management API 不返回照片

标签 facebook-graph-api facebook-workplace

我对 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

如您所见,它返回属于“核心”模式的其他字段,但缺少“照片”数组和其他字段。我认为这可能是因为用户没有任何照片,但几乎所有人都有个人资料照片,而且很多人还有更多。我尝试专门获取他们的用户信息,但遇到了相同的结果,没有照片。

有人试过类似的东西吗?非常感谢任何帮助,这对我们来说是一个障碍。

谢谢

最佳答案

要获取个人资料信息,请不要使用 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 {电子邮件}&limit=500

关于facebook-graph-api - Facebook Workplace Account Management API 不返回照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43806673/

相关文章:

java - 是否有像 Twitter Stream API 这样的 Facebook 实时流 API?

Facebook API : allow my own website to access my profile, 半永久

javascript - Facebook 与 javascript FB Graph api 集成 在墙上发布 Firefox 中的未知错误

javascript - 我可以在开放图中使用 fb.api 调用传递一些参数吗

typescript - Facebook Workplace 中的 BotFramework 集成

ios - Workplace by Facebook iPhone 应用程序支持哪些自定义 URL 方案?

facebook - 权限: manage_pages vs pages_show_list