0

How get response from podio api in format json or array but not object? I use podio-php (https://github.com/podio/podio-php)

My Code

    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 ?
Crown King
  • 35
  • 1
  • 6
  • What's wrong with an object? – ceejayoz Oct 19 '17 at 19:06
  • I don't know how get data from object as this PodioByLine Object ( [__attributes:PodioObject:private] => Array ( [type] => user [id] => 4286469 [avatar_type] => file [avatar_id] => 422384899 [image] => Array ( [hosted_by] => podio [hosted_by_humanized_name] => Podio [thumbnail_link] => https://d2cmuesa4snpwn.cloudfront.net/public/422384899 [link] => https://d2cmuesa4snpwn.cloudfront.net/public/422384899 [file_id] => 422384899 [external_file_id] => [link_target] => _blank ) [name] => FGfwegf fegfe – Crown King Oct 19 '17 at 19:16
  • 1
    So read the docs? http://podio.github.io/podio-php/objects/ – ceejayoz Oct 19 '17 at 19:19
  • Yes i read docs – Crown King Oct 19 '17 at 19:26
  • 1
    The docs explain how to use the object and its data, including code examples. – ceejayoz Oct 19 '17 at 19:33

1 Answers1

2

Let's assume you really need a JSON or array for some other reasons than "I don't know what to do with an object". So for JSON just use the as_json() function. And to get an array just typecast an object.

So:

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

But @ceejayoz is right in the comments above: object itself is fine, just RTFM :)