1

私は 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] => ) )

4

1 に答える 1