PHP client filterItems() by date range

Answered

Comments

6 comments

  • Kenneth Auchenberg

    Hi Anders,

    You need to send a bit different data-structure to the API when filtering. This is an example of the API communication needed:

    POST http://api.podio.com/item/app/2225/filter/

    Body:

    {

    "limit": 13,

    "filters": {

    "created_on": {

    "to": "2012-11-29",

    "from": "2012-11-08"

    }

    }

    }

    So in PHP you would need to something like:

    $body = array(

    'filters' => array(

    'created_on' => array(

    'to' => '2012-11-29',

    'from' => '2012-11-29'

    )

    )

    );

    Hope it clarified things a bit.

    //Kenneth Auchenberg

    Developer, Podio

    0
    Comment actions Permalink
  • Anders Hojmose

    Thanks Kenneth - that helped a lot!

    If anyone else is interested, this seems to do the job:

    $app_id = APP_ID;

    $field_id = "datefield"; // External ID of field to apply date filter

    $body = array(

    'filters' => array(

    $field_id => array(

    'from' => '2012-11-01',

    'to' => '2012-11-13'

    )

    ),

    limit => 6

    );

    $items = $api->item->filterItems($app_id, $body);

    0
    Comment actions Permalink
  • James Trusler

    Trying to do the same thing here and I'm not getting any items back ( I'm using the old PHP client ).

    I just created the 10th item in my app.

    http://pastebin.com/YXQzR8yp

    The code returns:

    Array (    [filtered] => 0    [total] => 10    [items] => Array        (        ) )

    So it's definitely the right app id because it's returning the "10" but it just can't filter out the brand new item I created.

    Any ideas?

    0
    Comment actions Permalink
  • James Trusler

    Never mind, had my date variables jumbled up :)

    0
    Comment actions Permalink
  • Samiul

    if i use this:

    $app_id = '2561625';

    $field_id = "19593751"; // External ID of field to apply date filter

    $body = array(

        'filters' => array(

            $field_id => array(

                'from' => '2013-05-01',

                'to' => '2013-06-20'

            )

        )

        

    );

    $items = PodioItem::filter($app_id ,$body);

     

    then i am getting this error:

     

    Fatal error: Uncaught PodioBadRequestError: "Invalid value "2013-06-20" (string): must be integer"
    Request URL: http://api.podio.com/item/app/2561625/filter/
    Request Body: {"filters":{"19593751":{"to":"2013-06-20","from":"2013-05-01"}}}

    Stack Trace:
    #0 /var/www/podio/podio-php/lib/Podio.php(269): Podio::request('POST', '/item/app/25616...', Array, Array)
    #1 /var/www/podio/podio-php/models/PodioItem.php(91): Podio::post('/item/app/25616...', Array)
    #2 /var/www/podio/pdio.php(121): PodioItem::filter('2561625', Array)
    #3 {main}
    thrown in /var/www/podio/podio-php/lib/Podio.php on line 206

    What is the prob?

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    What happens when you change $app_id and $field_id to be integers instead of strings?

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk