You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

迁移google/apiclient PHP库至v2:寻找原Google_Service_Plus_Person的domain属性

确认Google API Client v2中对应原Google_Service_Plus_Person的domain属性
  • 结论:People API里Organization对象的domain属性就是原Google+ Person模型domain属性的等效替代
  • 原Google+ API的Google_Service_Plus_Person::domain字段,用于存储用户所属工作/教育机构的域名;在People API中,这类组织相关的信息被整合到了people.organizations数组中,每个Organization对象的domain字段完全对应原属性的含义,即该组织的官方域名。
  • 迁移时的代码示例:
    旧v1代码(获取单个domain):
    $domain = $plusPerson->getDomain();
    
    新v2代码(从organizations数组中提取domain,需根据业务场景选择对应组织,比如主工作单位):
    $organizations = $person->getOrganizations();
    $domain = null;
    foreach ($organizations as $org) {
        // 可通过$org->getType()判断是工作/学校等类型,筛选目标组织
        if ($org->getType() === 'work') {
            $domain = $org->getDomain();
            break;
        }
    }
    

内容的提问来源于stack exchange,提问作者Artem Kurylo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 23:32:33