从响应对象访问created_on - 获取文件操作PODIO API

时间:2017-12-09 00:28:44

标签: php podio

大家好我试图使用下面的代码访问created_on对象,但它无效,我的日期January 1, 1970 12:00不正确。也尝试了

$item = PodioItem::get($item_id);
$file_id = "";
$created_on = "";
foreach ($item->files as $file) {
echo date('F j, Y h:i',strtotime($file->created_on))."<br>"; 
}

以下是来自print_r($file,true)的响应对象,我可以访问其他对象,而不会出现像$file->file_id, $file->link这样的任何问题。我想要完成的是将created_on数据存储在变量中,然后创建一个函数来检查并获取最新日期,然后获取它的file_id

 PodioFile Object

 [__attributes:PodioObject:private] => Array
        (
            [file_id] => 464714088
            [link] => https://files.podio.com/464714088
            [perma_link] => 
            [thumbnail_link] => 
            [hosted_by] => podio
            [name] => KEjj4UQSUV.PDF
            [description] => 
            [mimetype] => application/pdf
            [size] => 785849
            [created_on] => 2017-12-08 23:03:36
            [rights] => Array
                (
                    [0] => download
                    [1] => view
                    [2] => delete
                    [3] => update
                )

 PodioFile Object
(
    [__attributes:PodioObject:private] => Array
        (
            [file_id] => 464716575
            [link] => https://files.podio.com/464716575
            [perma_link] => 
            [thumbnail_link] => 
            [hosted_by] => podio
            [name] => IiaCfJjwws.PDF
            [description] => 
            [mimetype] => application/pdf
            [size] => 785849
            [created_on] => 2017-12-08 23:15:30
            [rights] => Array
                (
                    [0] => download
                    [1] => view
                    [2] => delete
                    [3] => update
                )

PodioFile Object
(
    [__attributes:PodioObject:private] => Array
        (
            [file_id] => 464728331
            [link] => https://files.podio.com/464728331
            [perma_link] => 
            [thumbnail_link] => 
            [hosted_by] => podio
            [name] => g6cmAeUCiV.PDF
            [description] => 
            [mimetype] => application/pdf
            [size] => 785849
            [created_on] => 2017-12-08 23:49:15
            [rights] => Array
                (
                    [0] => download
                    [1] => view
                    [2] => delete
                    [3] => update
                )

1 个答案:

答案 0 :(得分:0)

幸运的是,这里提供了样本答案 - https://hotexamples.com/examples/-/PodioItem/filter/php-podioitem-filter-method-examples.html

date_format($file->created_on, 'Y/m/d H:i:s')做了这个伎俩