我正在使用 Uploadcare 多次上传小部件,并在帖子中获取组 ID。当我调用 API 列出组中的文件时,我想提取有关每个文件的某些信息(uuid、mime_type、original_filename 等)。
这是我的代码:
$privateFiles = $_REQUEST['privateFiles'];
$ucApi = new Uploadcare\Api(public_key_removed, private_key_removed);
$group = $ucApi->getGroup($privateFiles);
$files = $group->getFiles();
foreach ($files as $ucFile)
{
echo $ucFile['uuid'];
}
当我尝试这样做时,我收到此错误:
Fatal error: Cannot use object of type Uploadcare\File as array
我肯定会从 API 中取回数据,但只是在尝试解析它时遇到了问题。这是我要返回的示例:
Array ( [0] => Uploadcare\File Object ( [re_uuid_with_effects:Uploadcare\File:private] => !/?(?P[a-z0-9]{8}-(?:[a-z0-9]{4}-){3}[a-z0-9]{12})(?:/(?:-/(?P(?:[^/]+/)+)))?(?[^/]*)! [uuid:Uploadcare\File:private] => 47ff1aa0-eebe-43d0-8803-0578455e82a1 [operations:Uploadcare\File:private] => Array ( ) [api:Uploadcare\File:private] => Uploadcare\Api Object ( [public_key:Uploadcare\Api:private] => public_key_removed [secret_key:Uploadcare\Api:private] => private_key_removed [api_host:Uploadcare\Api:private] => api.uploadcare.com [current_method:Uploadcare\Api:private] => GET [cdn_host] => ucarecdn.com [cdn_protocol] => https [retry_throttled:Uploadcare\Api:private] => 1 [userAgentName:Uploadcare\Api:private] => PHP Uploadcare Module [widget] => Uploadcare\Widget Object ( [api:Uploadcare\Widget:private] => Uploadcare\Api Object *RECURSION* ) [uploader] => Uploadcare\Uploader Object ( [host:Uploadcare\Uploader:private] => upload.uploadcare.com [api:Uploadcare\Uploader:private] => Uploadcare\Api Object *RECURSION* ) [version] => 1.5.5/5.6 [api_version] => 0.4 [defaultFilters:Uploadcare\Api:private] => Array ( [file] => Array ( [stored] => [removed] => ) ) ) [operation_list:Uploadcare\File:private] => Array ( [0] => crop [1] => resize [2] => scale_crop [3] => effect [4] => preview ) [cached_data:Uploadcare\File:private] => Array ( [uuid] => 47ff1aa0-eebe-43d0-8803-0578455e82a1 [original_file_url] => https://ucarecdn.com/47ff1aa0-eebe-43d0-8803-0578455e82a1/processes.txt [image_info] => [mime_type] => text/plain [is_ready] => 1 [url] => https://api.uploadcare.com/files/47ff1aa0-eebe-43d0-8803-0578455e82a1/ [original_filename] => processes.txt [datetime_uploaded] => 2016-10-20T19:28:44.314526Z [size] => 8543 [is_image] => [datetime_stored] => [datetime_removed] => [source] => [default_effects] => ) [default_effects] => [filename] => ) [1] => Uploadcare\File Object ( [re_uuid_with_effects:Uploadcare\File:private] => !/?(?P[a-z0-9]{8}-(?:[a-z0-9]{4}-){3}[a-z0-9]{12})(?:/(?:-/(?P(?:[^/]+/)+)))?(?[^/]*)! [uuid:Uploadcare\File:private] => 76e4fbca-0133-4863-838f-43b3e47a892e [operations:Uploadcare\File:private] => Array ( ) [api:Uploadcare\File:private] => Uploadcare\Api Object ( [public_key:Uploadcare\Api:private] => public_key_removed [secret_key:Uploadcare\Api:private] => private_key_removed [api_host:Uploadcare\Api:private] => api.uploadcare.com [current_method:Uploadcare\Api:private] => GET [cdn_host] => ucarecdn.com [cdn_protocol] => https [retry_throttled:Uploadcare\Api:private] => 1 [userAgentName:Uploadcare\Api:private] => PHP Uploadcare Module [widget] => Uploadcare\Widget Object ( [api:Uploadcare\Widget:private] => Uploadcare\Api Object *RECURSION* ) [uploader] => Uploadcare\Uploader Object ( [host:Uploadcare\Uploader:private] => upload.uploadcare.com [api:Uploadcare\Uploader:private] => Uploadcare\Api Object *RECURSION* ) [version] => 1.5.5/5.6 [api_version] => 0.4 [defaultFilters:Uploadcare\Api:private] => Array ( [file] => Array ( [stored] => [removed] => ) ) ) [operation_list:Uploadcare\File:private] => Array ( [0] => crop [1] => resize [2] => scale_crop [3] => effect [4] => preview ) [cached_data:Uploadcare\File:private] => Array ( [uuid] => 76e4fbca-0133-4863-838f-43b3e47a892e [original_file_url] => https://ucarecdn.com/76e4fbca-0133-4863-838f-43b3e47a892e/XPlaneInstallerLog.txt [image_info] => [mime_type] => text/plain [is_ready] => 1 [url] => https://api.uploadcare.com/files/76e4fbca-0133-4863-838f-43b3e47a892e/ [original_filename] => X-Plane Installer Log.txt [datetime_uploaded] => 2016-10-20T19:28:44.332926Z [size] => 5526 [is_image] => [datetime_stored] => [datetime_removed] => [source] => [default_effects] => ) [default_effects] => [filename] => ) )