Monday, 15 March 2010

podio - How do I know the argument should be an object and not array? -



podio - How do I know the argument should be an object and not array? -

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

above method of creating new contact. accepts 2 arguments, first integer workspace id, sec 1 contact object holds contact details.

referring here https://developers.podio.com/doc/contacts/create-space-contact-65590, know should first argument, workspace id.

however sec argument stated $attributes = array() in api doc array. assumed key value array of contact's properties. proceeded pass key value array sec argument so:

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

it kept failing work. after struggling , wasting 1 hour. tried pass contact object sec argument shown in origin of post. trial , error , wasting big amount of time, discovered should sec argument luck.

so question is, why api doc showing sec argument should array? documentation wrong or missing something? please tell me if did wrong here don't have trial , error , waste 1~2hours figure out sec argument.

it's much same thing. when pass in podio* object attributes parameter podio-php serialize calling as_json method on object (and it'll associative array). if kick podio-php debug mode can see what's beingness sent on wire: http://podio.github.io/podio-php/debug/

podio

No comments:

Post a Comment