简体   繁体   English

如何在PHP的Podio API中按电子邮件字段过滤项目?

[英]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> 我需要从包含电子邮件地址<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 我宁愿使用external_id而不是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. 在应用程序的“开发人员”部分,您可以找到带有电子邮件类型的字段的字段ID。 “开发人员”

If you will call filter by multiple emails, then Podio will return the result, if one of them will be found. 如果您将通过多封电子邮件调用过滤器,那么如果找到其中之一,Podio将返回结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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