简体   繁体   中英

How do I filter items by email field in Podio API for PHP?

I need to get an item from a collection of items that contains the email address <my-email>

Here is the structure of that part of the object:

[2] => PodioEmailItemField Object
                            (
                                [__attributes:PodioObject:private] => Array
                                    (
                                        [field_id] => <my-field-id>
                                        [type] => email
                                        [external_id] => email
                                        [label] => Email
                                        [values] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [type] => work
                                                        [value] => <my-email>
                                                    )

                                            )

This is the code I have tried:

$items = PodioItem::filter($app_id, array('filters'=>
                                    array(
                                          'email'=>
                                           array(
                                                'values'=>
                                                 array(
                                                       array(
                                                             'value'=>'<my-email>'))))));

but i keep getting the error:

Fatal error: Uncaught PodioBadRequestError: "Invalid value {"values": [{"value": "<my-email>"}]} (object): must be array" 

What am I missing here?

I would prefer to find this item using the external_id rather than the field_id

$items = \PodioItem::filter($app_id, [
    'filters' => [
        // replace 123456 with field ID for your field with email type
        '123456' => [
            'test1@example.com', 
            // 'test2@example.com',
            // 'test3@example.com'
        ]
    ]
]);

In the "Developer" section of your app you can find the field ID for your field with email type. “开发人员”

If you will call filter by multiple emails, then Podio will return the result, if one of them will be found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM