Search code examples
phppodio

How i can use filter in podio api for fields phone?


I need to get item that have this phone (example: 4355510510).

I wanted to use a filter method

$items = \PodioItem::filter(PODIO_APP_PHONE_CONTACT_ID2, array(
    'filters' => array(
        163435890=>[4355510510]
     )
        ));
print_r($items);

And I got this error

Uncaught PodioBadRequestError: "Filtering not supported for fields of type phone"

How can I get items that have the phone I need?

I can not use this example

$items = \PodioItem::filter(PODIO_APP_PHONE_CONTACT_ID2, array(
    'limit' => 500,
    'offset'=>0
));

 foreach ($items as $item) {
    foreach($item->fields['phones']->values as $phone){
         if(inval($phone) == 4355510510){
             $needMeItems[] = $item;
             break;
         }
    }
}
// rest code

Because I have more than 1000 items and each item has 1 or 2 unique phone numbers


Solution

  • Sorry, filtering is not supported for phone field. If you need to get item with specific phone you may use search or iterate over items. You may also consider re-design your app if phone number is the only way of getting to needed item.