dsn5510 2015-09-30 08:39
浏览 16

如何在php中读取此对象以检索电子邮件

This just one loop but I want retrieve all the emails.

Guzzle\Service\Resource\Model Object
(
    [structure:protected] => 
    [data:protected] => Array
        (
            [type] => user.list
            [pages] => Array
                (
                    [type] => pages
                    [next] => https://xxxx.com/users?per_page=50&page=2
                    [page] => 1
                    [per_page] => 50
                    [total_pages] => 234
                )

            [users] => Array
                (
                    [0] => Array
                        (
                            [type] => user
                            [id] => 560b99861cf5c8112a00012e
                            [user_id] => 
                            [anonymous] => 
                            [email] => abcd@gmail.com
                            [name] => Shivaji 
                            [pseudonym] => 
                            [avatar] => Array
                                (
                                    [type] => avatar
                                    [image_url] => 
                                )

                            [app_id] => xhxxxxf
                            [companies] => Array
                                (
                                    [type] => company.list
                                    [companies] => Array
                                        (
                                        )

                                )

                            [location_data] => Array
                                (
                                    [type] => location_data
                                    [city_name] => 
                                    [continent_code] => AS
                                    [country_name] => India
                                    [latitude] => 28.4667
                                    [longitude] => 77.0333
                                    [postal_code] => 
                                    [region_name] => Haryana
                                    [timezone] => Asia/Calcutta
                                    [country_code] => IND
                                )

                            [last_request_at] => 1443600774
                            [last_seen_ip] => 125.19.45.202
                            [created_at] => 1443600774
                            [remote_created_at] => 1443600686
                            [signed_up_at] => 1443600686
                            [updated_at] => 1443600774
                            [session_count] => 1
                            [social_profiles] => Array
                                (
                                    [type] => social_profile.list
                                    [social_profiles] => Array
                                        (
                                        )

                                )

                            [unsubscribed_from_emails] => 
                            [user_agent_data] => Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
                            [tags] => Array
                                (
                                    [type] => tag.list
                                    [tags] => Array
                                        (
                                        )

                                )

                            [segments] => Array
                                (
                                    [type] => segment.list
                                    [segments] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [type] => segment
                                                    [id] => 551d080b5e3a0fc0f4000043
                                                )

                                            [1] => Array
                                                (
                                                    [type] => segment
                                                    [id] => 551d080b5e3a0fc0f4000042
                                                )

                                        )

                                )

                            [custom_attributes] => Array
                                (
                                    [cust_id] => 
                                )

                        )
)
  • 写回答

1条回答 默认 最新

  • dougua9328 2015-09-30 09:55
    关注

    Try

    $users = $your_response_array["data"]["users"];
    foreach ($users as $user) {
        var_dump($user["email"] );
    }
    

    And if it is an object you're dealing with you need to use:

    $users = $your_response_obj->data["users"];
    

    But as your dump states the "data" array is protected so need to read the guzzle docs to find out which method gives you access to the data attribute.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度