print_r($item_collection['items']);
// Array of PodioItem instances
// PodioItem::filter is very powerful. You can filter and sort on almost any field. See all the details on https://developers.podio.com/doc/filters
// If you have a money field with a field_id of '1234' and you want to get all items in the app where the value is between 100 and 200:
$item_collection = PodioItem::filter(YOUR_APP_ID, array('filters' => array(1234 => array('from' => 100, 'to' => 200))));
// The following field types use the 'from' / 'to' format for filtering: number, money, calculation, progress, duration, date
// With other fields -- category, app reference, contact, question -- you provide an array of ids to match. E.g. if you want to get a collection of items where the app reference field with the field_id 5678 only matches items referencing items with the item_ids 1, 2 and 3:
$item_collection = PodioItem::filter(YOUR_APP_ID, array('filters' => array(5678 => array(1, 2, 3))));
// You can set sorting options and limit and offset values also. E.g. getting the 100 first items, sorted by their last edit date:
$item_collection = PodioItem::filter(YOUR_APP_ID, array('sort_by' => 'last_edit_on', 'sort_desc' => true, 'limit' => 100, 'offset' => 0));
// It's also doable to create new items from scratch (useful if you are migrating data from another system).
// Create the base item. Notice how you have to create a PodioApp instance. This is so we know what app to store the item in.
$item = new PodioItem(array('app' => new PodioApp(YOUR_APP_ID), 'fields' => array(), 'external_id' => 'my-legacy-id-number'));
// We can add some fields to the item:
$item->fields = array(new PodioTextItemField('title'), new PodioImageItemField('image-field'));
// Or you can use add_field and remove_field methods to add/remove fields one at a time:
$item->add_field(new PodioNumberItemField('number-field'));
// Field object must have a field_id or an external_id
$item->remove_field('number-field');
// Remove by field_id or external_id
// Notice how the external_id of the fields is being passed as the first argument to the constructor? When you create new instances of any of the Podio objects you can send three things to the constructor:
// 1. An associative array of properties. Like we did above when creating the item.
// 2. A string representing the external_id you want to set. Like we did for the PodioItemFields just above
// 3. An id value. Like we did for the PodioApp we attached to the PodioItem above.
// Give the fields values:
$item->field('title')->set_value('My title');
$item->field('image-field')->set_value(array(1, 2, 3));
// It is slightly cumbersome to first create the PodioItemFields and afterwards set the value for each one. You can set the values directly when creating the instances if you wish, but since the format is different for each field type it's often easier to call 'set_value' and have the formatting handled automatically.
// Finally save the item to Podio:
$item->save();