PodioContact::Get_All example

Answered

Comments

9 comments

  • Patrick Steil

    Try something more like this:

    $attributes = array(

    'filters' => array(

    'name' => 'value to search for'

    )

    );

    $contact = PodioContact::get_all($attributes);

    In all my code I have always used an actual "field ID" where I put 'name' above, but the external ID may work also... but if not, use the field ID... 

     

    Patrick Steil

    http://www.podiotools.com

    0
    Comment actions Permalink
  • Epicor

    Thanks Patrick,

     

    I get an error saying Invalid Filter filters. I will explain what I am trying to do because maybe I am doing it wrong. With a persons name, I am trying to return their profile ID so I can then assign this person to a contact field within the sales app.

     

    Would this be the correct way to achieve this?

     

    Thanks!

    -Ted

    0
    Comment actions Permalink
  • Patrick Steil

    How about posting your code so we can see what you have?  Haven't seen that error...  also, you may not be able to use the "filter" if this is a "text" field... might have to use the search api instead, but since it is a contact not sure... Andreas?

    0
    Comment actions Permalink
  • Epicor

    Here is the code I am using:

        $attributes = array('field' => array('name' => 'Eddy'));

        

        $contact = PodioContact::get_all($attributes);

               

        print $contact->profile_id;

     

    And the entire error message:

    Warning: urlencode() expects parameter 1 to be string, array given in C:\inetpub\wwwroot\Podio\podio-php-master\lib\PodioAPI.php on line 276 Invalid filter field

    0
    Comment actions Permalink
  • Epicor

    Sorry, here is the code. 'field' was left over from a test.

        $attributes = array('filters' => array('name' => 'Eddy'));

        

        $contact = PodioContact::get_all($attributes);

               

        print $contact->profile_id;

     

    And error:

    Warning: urlencode() expects parameter 1 to be string, array given in C:\inetpub\wwwroot\Podio\podio-php-master\lib\PodioAPI.php on line 276 Invalid filter filters

     

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Patrick, you are confusing the syntax for filtering items with the syntax for filtering contacts. They are not the same :)

    Theodore, your code is very close to being correct. I think there's just a slight confusion about the documentation. When it says {field} you can not supposed to create a "fields" property, you're just supposed to replace it with the name of the field.

    To find all contacts with 'Andreas' in their name:

    $contacts = PodioContact::get_all(array('name' => 'Andreas'));

    All the best,

    Andreas

    0
    Comment actions Permalink
  • Epicor

    Hi Andreas,

    Thanks for taking your time, if you look at my initial post this is the code I was initially trying but was not working. I am trying to access the profile_id as such, but get an error. Thanks.

     

    Code:

        $contact = PodioContact::get_all(array('name' => 'Eddy'));

               

        print $contact->profile_id;

     

    Error:

    Notice: Trying to get property of non-object in C:\inetpub\wwwroot\Podio\index.php on line 58

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Hi Theodore,

    The method returns an array of profile objects, not just a single object. So either iterate over the results or if you just want the first result: print $contact[0]->profile_id;

    /Andreas

    0
    Comment actions Permalink
  • Epicor

    Thanks for the help, this works well now.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk