如何从 podio api 以格式 json 或数组而不是对象获取响应?

How get response from podio api in format json or array but not object?

如何从跑道 api 获取格式为 json 或数组而非对象的响应? 我用跑台-php (https://github.com/podio/podio-php)

我的代码

    Podio::setup(CLIENT_ID_PODIO, CLIENT_SECRET_PODIO);
    $oauth = Podio::is_authenticated(); 
    Podio::authenticate_with_app(111111, 
              'bergbttyjra74d5afgrfhgrh781e70');
    //$items = PodioItem::filter(111111);
    $item = PodioItem::filter(111111, array(
        'filters' => array(
            'created_on' => array(
                "from" => "2017-10-09 00:00:00",
                "to" => "2017-10-19 23:59:59"
            )
        ),
    ));
   // print_r($item);// output object
 // how next ?

让我们假设您出于 "I don't know what to do with an object" 以外的其他原因确实需要 JSON 或数组。所以对于 JSON 只需使用 as_json() 函数。并获得一个数组 typecast an object.

所以:

 $json = $item->as_json(); // converts to json
 $array = (array) $item;   // converts to array

但是@ceejayoz 在上面的评论中是正确的:对象本身很好,只是 RTFM :)