这是Microsoft返回给我的$object
:
object(Microsoft\Graph\Model\Event)#56 (1) {
["_propDict":protected]=>
array(2) {
["@odata.context"]=>
string(245) "https://graph.microsoft.com/v1.0/$metadata#users('email%40outlook.com')/calendars('AAAAAAAAAAAAAAAAAAAAAAAA')/calendarView"
["value"]=>
array(0) {
}
}
}
我正在尝试检查value
的数组中是否不包含任何内容。我在访问“值”时遇到麻烦,因为它只是说数组。这是我已经尝试做的事情:
$object->array;
$object->array();
$object[0];
foreach ($object as $key) {
var_dump($key);
}
这些都不起作用。
我正在尝试做这样的事情:
if(empty($object->array['value'])) {
echo 'value is empty';
}
答案 0 :(得分:0)
Entity.getProperties()
function可以用于返回属性列表的目的。 Entity
是Event
实体的 base 类。
以下示例演示了如何使用array_key_exists
function确定实体是否包含属性:
$requestUrl = "https://graph.microsoft.com/v1.0/drives/$targetDriveId";
$drive = $this->client->createRequest("GET", $requestUrl)
->setReturnType(Model\Drive::class)
->execute();
$properties = $drive->getProperties(); //get all properties
if (array_key_exists('id', $properties)) { //verify for id property
print $properties["id"];
}