nshthmistry Posted February 28, 2014 Share Posted February 28, 2014 I have used Dropbox API in my website. I have completed Oauth and I'm successfully getting metadata. now i'm clueless.. MetaData: Metadata content for / Array ( [hash] => [thumb_exists] => [bytes] => 0 [path] => / [is_dir] => 1 => 0 bytes [root] => app_folder [contents] => Array ( [0] => Array ( [revision] => 20 [rev] => [thumb_exists] => 1 [bytes] => 6974 [modified] => Fri, 28 Feb 2014 11:02:10 +0000 [client_mtime] => Fri, 28 Feb 2014 11:02:10 +0000 [path] => /skhan.jpg [is_dir] => [icon] => page_white_picture [root] => dropbox [mime_type] => image/jpeg => 6.8 KB ) How can i use this metadata to show files to users? please help Quote Link to comment https://forums.phpfreaks.com/topic/286606-using-dropbox-api-in-php-how-to-show-files-in-user-interface/ Share on other sites More sharing options...
Solution Ch0cu3r Posted February 28, 2014 Solution Share Posted February 28, 2014 (edited) The metadata is an array. To get the information out of the array you need to loop through it. Example code to display files in a table echo '<p>There are ' . count($metadata['contents']) . ' files in ' . $metadata['path'] . ':</p> <table border=1 cellpadding=10> <tr> <th>Name</th> <th>Siize</th> </tr>'; foreach($metadata['contents'] as $file) { echo '<tr> <td>' . $file['path'] . '</td> <td>' . $file['size'] . '</td> </tr>'; } echo '</table>'; Edited February 28, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286606-using-dropbox-api-in-php-how-to-show-files-in-user-interface/#findComment-1471037 Share on other sites More sharing options...
nshthmistry Posted February 28, 2014 Author Share Posted February 28, 2014 Thanks for the reply.. I have used the above code, now i'm getting this error: Notice: Undefined variable: metadata Warning: Invalid argument supplied for foreach() Quote Link to comment https://forums.phpfreaks.com/topic/286606-using-dropbox-api-in-php-how-to-show-files-in-user-interface/#findComment-1471039 Share on other sites More sharing options...
nshthmistry Posted February 28, 2014 Author Share Posted February 28, 2014 Hey your answer was really helpful.. i made a little mistake.. now its solved Thanks Quote Link to comment https://forums.phpfreaks.com/topic/286606-using-dropbox-api-in-php-how-to-show-files-in-user-interface/#findComment-1471040 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.