If you haven’t read about Podio* objects yet, do so first.
Apps and app items form the core of Podio and for that reason podio-php tries to make it as easy as possible to read and manipulate app items.
Individual items
Get an item
There are multiple ways to get a single item from the API. All result in a PodioItem object. Which one you should use depends on what data you have available and how much data you need returned.
If you have the item_id you can use either PodioItem::get() or PodioItem::get_basic(). The first will return all auxiliary data about the item but is slower, the latter returns no auxiliary data.
If you have assigned an external_id to an item you can get the item by providing that external_id. Since external_ids are not unique you need to provide the app_id as well.
In a similar fashion each item in an app has a short numeric id called app_item_id. These are unique within the app, but not globally unique. It’s the numeric id you can see in the URL when viewing an item on Podio. You can also get an item by providing an app_id and the app_item_id.
The final option is to resolve an item URL and create an item that way. This is useful in cases where you only have the browser’s URL to work with (e.g. when creating browser extensions or when you are asking users to copy and paste URLs into your app).
Item fields
The most interesting part of an item is the fields attribute. Here the values for the item are found. If you’re doing any work with items it’s likely that you’re modifying fields in one way or another.
Fields are a special kind of PodioCollection – specifically a PodioItemFieldCollection. You can do all the thing you can do with a PodioCollection and then some.
Iterating over all fields
If you just want see all fields you can iterate over them.
Get field
You can access individual fields either by field_id or more likely by the human-readable external_id. To use the external_id simply pretend the collection is an associative array:
If you only have a field_id use the get() method to get the field:
Add field
You can add a field to the collection in the same way you add items to normal arrays. If you add a field that already exists the current one will be replaced.
You can also create everything in one step:
Remove field
You remove a field either by unset (if you have the external_id) or by calling the remove() method.
The format varies a bit from field to field. You can see examples for all field types under Item field examples. After you have changed the value of the field you must save your change back to the API. If you only change a single field you can save just that field, but if you are changing multiple fields it can perform better to save the entire item.
Create item
To create a new item from scratch you create a new PodioItem without an item_id, attach your fields and call the save method.
Modifying items
Updating items are handled exactly the same way as creating items. If an item’s item_id is set it will be updated once you call the save() method.
Often you will be fetching an existing item, making modifications and saving those changes:
You can also create the PodioItem object from scratch and save:
Item collections
One of the most common operations is getting a collection of items from an app, potentially with a filter applied. For this you can use PodioItem::filter(). It returns a collection with two additional properties: filtered (total amount of items with the filter applied) and total (total amount of items in the app). You can iterate over this collection as normal.
Important: You can use both field_id and external_id when filtering items. The examples below all use field_id for brevity.
You can filter on most fields. Take a look at the API reference for a full list of filter options. When filtering on app fields use the field_id or external_id as the key for your filter. Some examples below: