0
$new_contact = PodioContact::create( 
                    2144836,
                    new PodioContact(
                    array('name' => $name,'title'=>$title, 'organization'=>$org, 'phone' => $phone, 'mail' => $email)
                    )  
                );

Above is the method of creating a new contact. It accepts 2 arguments, first is a integer for workspace id, the second one is an Contact object which holds the contact details.

Referring to here https://developers.podio.com/doc/contacts/create-space-contact-65590, I clearly know what should be the first argument, which was the workspace id.

However the second argument is stated as $attributes = array() in the API Doc which is an array. I ASSUMED this to be a key value array of the contact's properties. I proceeded to pass a key value array into the second argument like so:

$new_contact = PodioContact::create( 
                    2144836,
                    array('name' => $name,'title'=>$title, 'organization'=>$org, 'phone' => $phone, 'mail' => $email)
                );

It kept failing to work. After struggling and wasting 1 hour. I simply tried to pass an Contact Object as the second argument as shown in the beginning of this post. So with this trial and error and wasting a large amount of time, I discovered what should be the second argument by luck.

So my question is, why is the API Doc showing the second argument should be an array? Is the documentation wrong or am I missing something? Could you please tell me if I did anything wrong here so I don't have to trial and error and waste 1~2hours to figure out the second argument.

Armesh Singh
  • 405
  • 2
  • 5
  • 12
  • Don't doubt yourself. You tested and know what works. Ask podia about their API docs. Maybe they just changed the function and forgot to update the docs. –  Oct 11 '14 at 04:36

1 Answers1

2

It's really much the same thing. When you pass in a Podio* object as the attributes parameter podio-php will serialize it by calling the as_json method on that object (and it'll then be an associative array). If you kick podio-php into a debug mode you can see exactly what's being sent over the wire: http://podio.github.io/podio-php/debug/