Post

3 followers Follow
1
Avatar

Announcement: New PHP client available

To make it easier to build integrations using PHP I have just flipped the switch on a new version of the PHP client library. Some highlights:

  • Classes/models for almost all parts of the API. You get proper objects and you no longer have to wade through complicated JSON (with a few exceptions)
  • Nice helper methods for working with items and fields
  • Many new code examples (in the 'examples' folder)
  • More easily accessible logging for debugging purposes
  • Automatic session handling for storing access tokens between page requests

Grab the code here:  https://github.com/podio/podio-php

The basic syntax has changed (to facilitate the new classes and make it easier to extend going forward) and I encourage you to check out the code samples in the readme file and in the 'examples' folder.

PHP 5.3 is now a requirement. The client relies in it's foundation on some features that are only available in PHP 5.3.

I hope you will give the new release a go and take advantage of all the new features. Then let us know here what areas could be easier to work with.

Pull requests on github are always welcome.

Andreas Haugstrup Pedersen Answered

Please sign in to leave a comment.

11 comments

0
Avatar

Andreas, so what about our existing code, can we integrate this new API into our app without having to rewrite what we have and slowly migrate, or do we have to go ahead and migrate our entire app to use this new structure?

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

Hi Patrick,

You can sort-of slowly migrate. Meaning that there are some things you must change all at once, and others you can do step-by-step.

Changes you must make

Whenever you make an API call the syntax has changes. You are no longer passing around a singleton API object. You can now make API calls directly on the classes. So $api->task->get(123); becomes PodioTask::get(123); While boring, these changes are easy to make.

In addition some method names changed. I did this to get consistency across the different areas and to avoid redundant naming. So $api->spaces->getTopSpaces() became PodioSpace::get_top()

Changes you can make gradually

More complicated for you is that the return values are now proper objects instead of JSON arrays. You will love this in the future, but the migration might be a little annoying.

For example when you get an item the item title is no longer in $item['title'] it is in $item->title. This of course is more annoying with the nested structured. The author's name of the item is no longer in $item['initial_revision']['created_by']['name'] but in $item->initial_revision->created_by->name

Going forward you will get a ton of benefits of the new structure as your code will be much easier to maintain.

However! The old structure is still available if you want it. You can access the old-style JSON array in the 'attributes' property. So you can still do $item->['attributes']['title']. This way you can change things over gradually by doing something like this

$item = PodioItem::get(123);

$item = $item->attributes;

// Much old code below will work without changes

// Nested structures will still needs to be massaged a bit 

Does that make sense?

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Great, thanks Andreas!

Are there any new API calls added in this version?

Do you have a summary of all the API name changes documented yet?  

Thanks!

Patrick Steil

http://www.podiotools.com 

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

I added almost all missing api calls. The ones I didn't add are in fringe areas of the API. Like Bulletin, Connections etc. If someone needs those I'll add them in, but I highly doubt anyone does. All the important things that were missing are now available (like Views).

I don't have a summary of the names that changed. It was all manual labor and I didn't keep track while I was doing it.

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

There's already way more documentation for this version than the previous one. :)

All the code examples on the developer website have been updated and in addition there are now a ton more examples in the download itself (look in the 'examples' folder). If you're looking for something specific feel free to create a question in this forum. :)

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Oh, sweet, thanks... sorry hadn't realized that!  :)

Is the V2 documentation still available?  Please leave that up somewhere for a while... :)

Patrick Steil

http://www.podiotools.com

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

The code examples on the developer website are gone, if you need something specific I can find them for you. Fortunately the function arguments are the same so when you read the tutorial for dealing with Items you the values you pass to the functions are the same.

The old README (which had the most information anyway) is still available in the download for the old version in my previous reply. :)

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Dear Andreas,

Thanks for the API, I think I'm missing an api call. To join a space. It was there in the previous version under SpaceMember, but I can't find it anymore now.

I think you should add this to PodioSpaceMember.php

/**

* @see https://developers.podio.com/doc/space-members/join-space-1927286

*/

public static function join($space_id) {

  return Podio::post("/space/{$space_id}/join");

}

Peter van den Broek 0 votes
Comment actions Permalink