I printed out the array and I see the response in the sandbox perfectly fine, the problem is this structure seems too complicated to handle, especially when trying to pass the response back to JS for a AJAX response.

For example, here is part of my array print out:

Array

(

[0] => Array

(

[status] => active

[external_id] => title

[config] => Array

(

[description] => Donor's full name (used for interacting with other apps)

This works, I get the response I need EXCEPT when the donor has no phone, now the index (3) I hard set is now the email because the array does not keep that value since its empty. This is only a small sample of the issue. I need to be able to call what field I want by name.

Also, the $student array there is my attempt to get an app_reference field, but again it seems impossible to pull the data as needed.

I don't think this is the best way by any means because of the multiple calls, but looking through the PodioItem.php I found the getFieldValue(). But in a situation like mine instead of having one call with the getItems() I now had 4, plus a loop of more for each app reference item. Here's the code so you can see what I mean.

getFieldValue will probably make your code run rather slow as you'll have a ton of API calls. It's better to use filterItems (which is like getItems, but with simpler syntax) and then create a helper function that can loop over the fields to find one by name.

As you've both discovered you can't rely on the array indexes as they will change when not all fields have values. The helper function will get around this.

I was going to keep this a secret a bit longer, but since it relates directly to your problems... For the past month I have been working on a replacement for the PHP API client specifically to make the things you want to do easier. Juggling those big arrays gets really annoying.

Beware that I've no documentation yet so you'll have to read the code to play with it. The main change is moving away from using a singleton instance for the main api object to using static methods for raw API calls (e.g. PodioItem::get() for getting a single item) and then instantiating specific objects for the different types of data that the API returns.

This will allow me to create nice instance methods for e.g. items to avoid having to do all the hard work manually each time. E.g. in this case it would be useful to just do:

print $field->humanized_value(); // humanized_value would be a method that translates the raw value into a print-friendly version

Right now this new version is just as good as the old version. I still need to update all the documentation before I can release it. After that I will start adding convenience methods such as "get field by name". If you have any more wishes for convenience methods let me know (here or via email haugstrup@podio.com ).

Nice work with the PHP3 library Andreas! I actually started to build something similar (although a lot less feature rich) for a project I'm working on. Do you have any idea when this branch will be production ready?

You can start using it right now for production work. What's there is solid. I just need to add additional stuff (documentation, bring examples up to date and add the first round of instance methods) before I flip the switch and make it the official PHP library.

So you should feel completely safe checking out that branch and working with it. I promise I won't break it :)

As I said above the syntax is different in the upcoming version. This includes initialization and authentication which is done slightly different (going away from using a singleton to using static methods). You'll need to be able to read and understand the code -- otherwise you should stick with the old version until I get everything packaged up nicely. Hopefully, I'll get that done soon!

PS. init and authenticate like this (but you'll run into other errors afterwards since the syntax for making api calls also changed):

Andreas this looks like great stuff, I just started a project last week with the old way but now before it gets too developed I wanted to implement these changes. One issue I'm having getting started I think is because I'm trying to build my own reusable class. So at the moment I'm making this call:

Line 4 of PodioAPI.php will give you the answer: "Podio PHP library requires PHP 5.3 or higher."

I had to drop support for PHP version 5.2 and below for many many reasons (specifically late static bindings). There's no way to get things running unless you are on PHP 5.3 or above. You really really really should upgrade regardless. PHP 5.2 received it's last update in 2010 and is no longer supported by the PHP community. It's nothing but a security risk these days.