[英]PODIO php API call, get array offset of all item fields value using filter by app ID
I'm new in API thing, I'm using PHP CLient of PODIO link here , I want to get all fields value of all items. 我是API方面的新手,我在这里使用PODIO链接的PHP CLient,我想获取所有项目的所有字段值。
The code below is not working, but if I used PodioItem::get_basic(item_id)
, this work to get item related values but I want to get all fields value of all items so I used filter by app ID, I'm getting an error Undefined property: PodioItemCollection::$fields
下面的代码无法正常工作,但是如果我使用
PodioItem::get_basic(item_id)
,则可以获取与项目相关的值,但是我想获取所有项目的所有字段值,因此我使用了按应用ID过滤的功能,错误Undefined property: PodioItemCollection::$fields
<?php
require_once '/PodioAPI.php';
$client_id = "xxxx";
$client_secret = "xxxx";
$app_id = xxxx;
$app_token = "xxxx";
Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);
$item = PodioItem::filter($app_id);
$field_id = 'dashboard-link-2';
$collection = $item->fields[$field_id]->values;
foreach ($collection as $embed) {
print "Embed id: ".$embed->embed_id."<br>";
print "Embed URL: ".$embed->original_url."<br>";
}
Here's the full response in 2 items available in APP on JSON format using print $item->as_json(true)
. 这是使用
print $item->as_json(true)
在JSON格式的APP中可用的2个项目的完整响应。 I want to do for each
in all fields and their value on the last part of JSON. 我想对所有字段中的
for each
字段及其在JSON的最后一部分上的值进行处理。
{
"item_id":535780740,
"title":"test",
"link":"https:\/\/podio.com\/trackzen\/",
"rights":[
"view",
"comment",
"rate",
"add_task",
"add_file",
"update",
"add_conversation",
"subscribe"
],
"created_on":"2016-12-26 05:58:59",
"app_item_id_formatted":"2",
"app_item_id":2,
"ratings":{
"like":{
"average":null,
"counts":{
"1":{
"total":0,
"users":[
]
}
}
}
},
"last_event_on":"2016-12-30 10:47:34",
"comment_count":3,
"created_by":{
"type":"user",
"id":3584284,
"avatar_type":"file",
"avatar_id":250835059,
"image":{
"hosted_by":"podio",
"hosted_by_humanized_name":"Podio",
"external_file_id":null,
"link_target":"_blank"
},
"name":"Marlon"
"url":"https:\/\/podio.com\/users
"avatar":250835059
},
"created_via":{
"id":1,
"auth_client_id":1,
"name":"Podio",
"display":false
},
"initial_revision":{
"created_on":"2016-12-26 05:58:59",
"created_by":{
"type":"user",
"id":3584284,
"avatar_type":"file",
"avatar_id":250835059,
"image":{
"hosted_by":"podio",
"hosted_by_humanized_name":"Podio",
"file_id":250835059,
"external_file_id":null,
"link_target":"_blank"
},
"name":"Marlon",
"url":"https:\/\/podio.com\/users\/",
"avatar":250835059
},
"created_via":{
"id":1,
"auth_client_id":1,
"name":"Podio",
"display":false
}
},
"current_revision":{
"revision":13,
"created_on":"2016-12-30 10:47:34",
"created_by":{
"type":"user",
"id":3584284,
"avatar_type":"file",
"avatar_id":250835059,
"image":{
"hosted_by":"podio",
"hosted_by_humanized_name":"Podio",
"external_file_id":null,
"link_target":"_blank"
},
"name":"Marlon",
"url":"https:\/\/podio.com\/users\",
"avatar":250835059
},
"created_via":{
"id":1,
"auth_client_id":1,
"name":"Podio",
"display":false
}
},
"fields":{
"title":"test",
"service":[
536114669
],
"dashboard-link-2":[
{
"embed":156461816,
"file":null
}
],
"text":"
TEST
<\/p>",
"action":[
1
],
"deliverables":[
536600856
]
}
}{
"item_id":535312848,
"title":"Test Dashboard",
"rights":[
"view",
"comment",
"rate",
"add_task",
"add_file",
"update",
"add_conversation",
"subscribe"
],
"created_on":"2016-12-24 09:25:08",
"app_item_id_formatted":"1",
"app_item_id":1,
"ratings":{
"like":{
"average":null,
"counts":{
"1":{
"total":0,
"users":[
]
}
}
}
},
"last_event_on":"2016-12-28 12:37:26",
"comment_count":23,
"created_by":{
"type":"user",
"id":3584284,
"avatar_type":"file",
"avatar_id":250835059,
"image":{
"hosted_by":"podio",
"hosted_by_humanized_name":"Podio",,
"file_id":250835059,
"external_file_id":null,
"link_target":"_blank"
},
"name":"Marlon",
"url":"https:\/\/podio.com",
"avatar":250835059
},
"created_via":{
"id":1,
"auth_client_id":1,
"name":"Podio",
"display":false
},
"initial_revision":{
"created_on":"2016-12-24 09:25:08",
"created_by":{
"type":"user",
"id":3584284,
"avatar_type":"file",
"avatar_id":250835059,
"image":{
"hosted_by":"podio",
"hosted_by_humanized_name":"Podio",
"external_file_id":null,
"link_target":"_blank"
},
"name":"Marlon",
"url":"https:\/\/podio.com\/users\/",
"avatar":250835059
},
"created_via":{
"id":1,
"auth_client_id":1,
"name":"Podio",
"display":false
}
},
"current_revision":{
"revision":6,
"created_on":"2016-12-28 12:37:26",
"created_by":{
"type":"user",
"id":3584284,
"avatar_type":"file",
"avatar_id":250835059,
"image":{
"hosted_by":"podio",
"hosted_by_humanized_name":"Podio",
"thumbnail_link":"https:\/\/d2cmuesa4snpwn.cloudfront.net\/public\/",
"link":"https:\/\/d2cmuesa4snpwn.cloudfront.net\/public\/",
"file_id":250835059,
"external_file_id":null,
"link_target":"_blank"
},
"name":"Marlon",
"url":"https:\/\/podio.com\/users\/",
"avatar":250835059
},
"created_via":{
"id":1,
"auth_client_id":1,
"name":"Podio",
"display":false
}
},
"fields":{
"title":"Test Dashboard",
"service":[
535311650,
536114669
],
"dashboard-link-2":[
{
"embed":155910622,
"file":null
}
],
"action":[
1
],
"deliverables":[
535312645,
535312468,
535312239,
535312097,
535311935,
536114763,
536114718
]
}
}
You'll want to iterate through the fields array to find the field with the external_id
equal to what you are looking for. 您将要遍历fields数组以找到
external_id
等于您要查找的字段。 It look like you are looking for the field with external_id == 'dashboard-link-2'
看起来您正在寻找具有
external_id == 'dashboard-link-2'
的字段
Edit #1 Added example: 编辑#1添加了示例:
$collection = []
foreach ($item->fields as $field) {
if ($field->external_id == "dashboard-link-2") {
$collection = $field->values;
}
}
Edit#2: Had a look at the Docs, my code is for an older/different version of the Library. 编辑#2:看一下文档,我的代码适用于旧版/不同版本的库。 Sorry
抱歉
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.