Getting data from the API Call
AnsweredI have a problem with getting the data out of an API call. My call is:
$string = PodioItem::filter_by_view($app_id,$view_id);
I am using PHP, and the encoding doesn't seem to want to play nicely.
Looking at the structure, I can see that json_decode won't work, but neither does conventional array commands.
This doesn't work either:
echo $string['items']['notes'][0]['value'];
I've looked through all the API docs and can't find any specific examples on how to do this.
Can anyone help?
-
Hi Jon,
PodioItem::filter_by_view() doesn't return a string. podio-php does a lot of work for you under the hood. What you get is an array with three properties: filtered and total which contains the filtered and total counts and then "items".
"items" is an array of PodioItem objects. Podio items are rather complex sizes and it can quickly become complicated to work with the raw data. So podio-php has a nice class for the purpose (actually almost all methods return some form of object rather than plain hashes).
Some examples of what you can do with PodioItem objects (and the related fields): https://github.com/podio/podio-php/blob/master/examples/items.php
/Andreas
-
Thanks Andreas, I'm trying to follow the example, but it still doesn't seem to work:
$itemsarray = PodioItem::filter_by_view($app_id,$view_id);
if (is_array($itemsarray)) {
foreach($itemsarray as $items) {if (is_array($items)) {
foreach($items as $item) {
echo $item->title;
echo $item->due;
}
}}
}This prints out the title, but not the due date.
Please sign in to leave a comment.
Comments
4 comments