Search for space contact with email?

Answered

Comments

22 comments

  • Andreas Haugstrup Pedersen

    You can't test out the filters in the API sandbox because the key is dynamic. You can only do it in your actual code. You need to use 'mail' I believe for the key and then the email address as the value.

    0
    Comment actions Permalink
  • Carl-Fredrik Herö

    Ok, so the parameters in my screenshot it correct?

    0
    Comment actions Permalink
  • Patrick Steil

    Interested in this answer also... 

    0
    Comment actions Permalink
  • Casper Fabricius

    No, that sandbox form is broken. We should in fact hide the {field} parameter as it doesn't work, but the whole thing is autogenerated from (of course) data in Podio, so we haven't gotten around to that.

    You request would have to include &mail=bhll_8766@veryrealemail.com to be correct, but as Andreas pointed out, you can't make that request from the sandbox form, you have to do it from you own code to test it out.

    0
    Comment actions Permalink
  • Carl-Fredrik Herö

    Thanks Casper! I got it to work! :)

    0
    Comment actions Permalink
  • Patrick Steil

    Casper, et. al... can someone post the code necessary to do a search based on email address to determine if a space contact already exists?

    That would be greatly appreciated!  :)

    Thanks!

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Use https://developers.podio.com/doc/contacts/get-space-contacts-22414

    $contacts = PodioContact::get_for_space( $space_id, array('mail' => 'myemail@example.com') );

    0
    Comment actions Permalink
  • Patrick Steil

    Thanks!  Will try now... 

    0
    Comment actions Permalink
  • Patrick Steil

    What type of Auth does this require?  If user, that won't work for me as I need to use Auth... my current code is actually using PodioItem::filter to retrieve every Item and then is able to loop over the returned items to get to the contacts... so I have access using App Auth... what I need is a much more efficient way to get to this data as the method I am using has finally caused us to start timing out... 

     

    Can that api be opened up for use by App Auth?

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    App auth provides access to a single app. Space contacts has access to all contacts on that space, without regard for which apps they are used in. So it cannot be used with app auth.

    If you get the correct data when fetching items you can continue to do that? I don't know what you mean by timing out, so I can't suggest any direction there. Most likely it'll make sense for you to process fewer items at the time?

    /Andreas

    0
    Comment actions Permalink
  • Patrick Steil

    When there are hundreds of contacts in the workspace, then it takes a long time - 10-20 seconds or more to retrieve all the items in order to loop over them in my PHP code... this is a big drain on Podio and my app... and now it is causing problems on our server... 

    What we really need is an api specifically that can just tell me if the email address exists as a space contact... since I can get to that info by looping over every item in the App, it would make sense that maybe you all could consider opening this up somehow via the API... 

    This is a huge need!  :)  

    Thanks!

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    I'll add the "Get contacts in app" as a feature request on our end. I'm not sure if it's actually feasible or not.

    All this is something you can cache on your end though. You should not have to loop over all existing items more than once. After that you can setup a webhook for all contact fields so you can be told when a contact reference changes (and for when items are created, of course). Create a local cache of the data you need to check and only fetch items again when they have actually changed.

    /Andreas

    0
    Comment actions Permalink
  • Patrick Steil

    Ok, I can go down that road, but it sure would be a heck of lot easier to just make one quick api call... 

     

     

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    I agree. If you don't want to bother with webhooks you can also just store a timestamp for the last time you checked the app and then use PodioItem::filter() with a sort order on last edited date and only fetch items until you reach the time you last checked. Then you will not be searching through the entire app each time. Again with a local cache.

    0
    Comment actions Permalink
  • Patrick Steil

    Can I call PodioItem::filter and only retrieve items since that date/time?  What would that look like?

    0
    Comment actions Permalink
  • Patrick Steil

    Please also consider offering a "Get contacts in app" API call... this would be so much lighter for both sides... I feel like I am having to pull way too much data from Podio to do this and I have to do this on EVERY time we process a new email into Podio... thanks... 

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    You can't filter on last_edit_on, but you can sort on it. So you'd sort by that and go through items until you reach a last_edit date that's prior to your last data gathering. That way you're sure to have the most recent information since a particular time. Again, you should cache locally so you're not going through all items all the time.

    0
    Comment actions Permalink
  • Patrick Steil

    Andreas, I still feel like there should be an API for this... I don't want to have the expense of doing this nor do I want to make Podio work this hard to return all this data... :)

    And consider this:

    1.  If I was a user of an App then I would have access to the space contacts (granted I guess I would have access to the whole space, but how do you handle this for a user who access to one sole item?  Wouldn't they be able to access space contacts to setup a new contact on an item?

    2.  Since I can already get to this data by looping over all items, it is not introducing any new security risk to allow this api call... 

    Thanks for your consideration...  

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    We're working on it :)

    0
    Comment actions Permalink
  • Patrick Steil

    Yeah!  :)

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Alright, pull the newest version of podio-php and give PodioContact::get_for_app($app_id, array('mail' => 'sample@example.com')); a try

    0
    Comment actions Permalink
  • Patrick Steil

    Woo hoo Andreas, thanks!!!!!  (Sorry, didn't see the email on this until today... )

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk