我正在使用Podio API,这是我的代码:
CellMeasurer
这就是它的回报:
Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);
$items = PodioItem::filter($app_id);
print "My app has ".count($items)." items<br><br>";
foreach($items as $item){
print $item->fields['First']->values; //THIS IS LINE 42
print $item->fields['Last']->values; //THIS IS LINE 43
}
(我上面标有哪些行是第42和43行)
在玩完代码后,我发现My app has 2 items
Notice: Trying to get property of non-object in C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php on line 42
Notice: Trying to get property of non-object in C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php on line 43
Notice: Trying to get property of non-object in C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php on line 42
Notice: Trying to get property of non-object in C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php on line 43
Fatal error: Uncaught exception 'PodioDataIntegrityError' with message 'Field must have id or external_id set.' in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioFieldCollection.php:31 Stack trace: #0 C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioItemFieldCollection.php(48): PodioFieldCollection->offsetSet(NULL, Object(PodioTextItemField)) #1 C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\lib\PodioCollection.php(16): PodioItemFieldCollection->offsetSet(NULL, Object(PodioTextItemField)) #2 C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioFieldCollection.php(15): PodioCollection->__construct(Array) #3 C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioItemFieldCollection.php(36): PodioFieldCollection->__construct(Array) #4 C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php(53): PodioItemFieldCollection->__construct(Array) #5 {main} thrown in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioFieldCollection.php on line 31
为NULL(因此我认为$item->fields['First']
也是NULL。但我不知道为什么会这样,我知道这个事实这个应用程序有“First”和“Last”字段,这些字段中包含数据。
有谁知道这里发生了什么?
答案 0 :(得分:0)
我在C#中使用过podio api,所以我对你的代码的理解可能是错的,所以我在这里理解的是,print $item->fields['First']->values;
试图获得字段的字段值首先,现在如果你想通过这里字段的外部id,你传递错误,因为字段外部Id总是以小写字母开头,这意味着它应该看起来像
$item->fields['first']
您可以在该应用
的开发者选项中找到此外部ID