我目前正在使用SDK来检索网上论坛的详细信息。从Group模型来看,有很多显示数据的方法。
当我print_r()
进行分组时,它将返回一个具有受保护的_propDict属性的Group对象。问题是,其中一些无法通过吸气剂访问,例如:
Microsoft\Graph\Model\Group Object
(
[_propDict:protected] => Array
(
[id] => XX-YY-ZZ
[deletedDateTime] =>
[classification] =>
[createdDateTime] => 2019-04-18T15:09:57Z
[creationOptions] => Array
(
[0] => Team
[1] => classAssignments
[2] => ExchangeProvisioningFlags:2509
)
[description] =>
[displayName] => Example Group
[groupTypes] => Array
(
[0] => Unified
)
[mail] => test@example.com
[mailEnabled] => 1
[mailNickname] => ExampleGroup
[onPremisesLastSyncDateTime] =>
[onPremisesSecurityIdentifier] =>
[onPremisesSyncEnabled] =>
[preferredDataLocation] =>
[proxyAddresses] => Array
(
[0] => SPO:SPO_ABCDE123456
[1] => SMTP:test@example.com
[2] => smtp:rest@example.onmicrosoft.com
)
[renewedDateTime] => 2019-04-18T15:09:57Z
[resourceBehaviorOptions] => Array
(
[0] => HideGroupInOutlook
[1] => WelcomeEmailDisabled
[2] => ConnectorsDisabled
[3] => SubscribeNewGroupMembers
)
[resourceProvisioningOptions] => Array
(
[0] => Team
)
[securityEnabled] =>
[visibility] => HiddenMembership
[extension_ABC123_Education_ObjectType] => Section
[onPremisesProvisioningErrors] => Array
(
)
)
)
因此,例如,目前没有获取deletedDateTime
或createdDateTime
的方法。我也想获得extension_ABC123_Education_ObjectType
值。
是否有使用Group模型执行此操作的简便方法?
谢谢
答案 0 :(得分:2)
问题是,其中一些无法通过吸气剂访问
实际上,在这种情况下,可以考虑采用以下方法通过msgraph-sdk-php
进行检索。
让我们假设每个组公开了一个扩展数据,并将其命名为<p>Some text with <a href="#">a simple link</a></p>
<p><a href="#" class="btn"><span>A button</span></a></p>
<p><a href="#" class="btn btn-outline"><span>An other button</span></a></p>
:
contoso_grpstatus
其中GET https://graph.microsoft.com/v1.0/groups/{group-id}?$select=displayName,description,contoso_grpstatus
{
"displayName": "Group 123",
"description": "Group 123",
"contoso_grpstatus": {
"@odata.type": "#microsoft.graph.ComplexExtensionValue",
"Status": "Active"
}
}
是schema extension
contoso_grpstatus
然后可以引入扩展 {
"id": "contoso_grpstatus",
"description": "Contoso - Group status",
"targetTypes": [
"Group"
],
"status": "Available",
"owner": "d1433ee1-b39b-49b0-b022-b1072a0aee38",
"properties": [
{
"name": "Status",
"type": "String"
}
]
}
的自定义Group类:
\Microsoft\Graph\Model\Group
最后,可以像这样检索组属性(class GroupWithStatus extends \Microsoft\Graph\Model\Group{
public function getStatus()
{
if (array_key_exists("contoso_grpstatus", $this->_propDict)) {
return $this->_propDict["contoso_grpstatus"];
} else {
return null;
}
}
}
)和自定义数据(DisplayName
):
contoso_grpstatus