Giter VIP home page Giter VIP logo

Comments (4)

Caster avatar Caster commented on August 15, 2024

Hey @jeffreyflukman,

I know I'm not the developer, but I saw your issue by accident and since I have created a testfile that does exactly this, I thought I might share it with you. There you go.

<?php

/**
 * 1. Authenticate user.
 * 2. Retrieve account information.
 * 3. Retrieve file information.
 */

// Require the bootstrap
require_once('bootstrap.php');

// Retrieve the account information
$accountInfo = $dropbox->accountInfo();
$metaData = $dropbox->metaData();

// Output
?>
<html>
  <head>
    <title>DropboxAPI Test</title>
    <style type="text/css">
      .main {
        width: 1000px;
        margin: 0 auto;
        border: 1px solid black;
      }

      .accountInfo {
        width: 80%;
        margin: 10 auto;
        padding: 10px;
        border-bottom: 1px solid black;
      }

      .welcome {
        font-weight: bold;
        text-align: center;
      }

      .fileInfo {
        width: 80%;
        margin: 10 auto;
        padding: 10px;
        border-bottom: 1px solid black;
      }

      .fileList {
        list-style-type: none;
        margin: 0;
        padding: 0;
      }

      .fileListItem {
        width: 100%;
        position: relative;
        padding-left: 50px;
      }

      .fileImage {
        display: inline-block;
        width: 20px;
        height: 20px;
        background: white url('/images/pdficon_16x16.png') no-repeat center center;
        vertical-align: center;
      }

      .fileSize {
        position: absolute;
        right: 100px; /* twice padding-left to make sure left- and right space are equal */
      }

      .debug {
        display: none;
        width: 80%;
        margin: 10 auto;
        padding: 10px;
        font-size: 80%;
        white-space: pre-wrap;
        white-space: -moz-pre-wrap;
        white-space: -o-pre-wrap;
        background: #faf8f0;
        border: 1px solid red;
      }
    </style>
  </head>
  <body>
    <div class="main">
      <div class="accountInfo">
        <p class="welcome">Hello <?php echo($accountInfo['body']->display_name); ?>!</p>
      </div>
      <div class="fileInfo">
<?php if (count($metaData['body']->contents) > 0) : ?>
        <p class="fileHeader">This is a list of all files in your [APP] Dropbox.</p>
        <ul class="fileList">
<?php
  foreach ($metaData['body']->contents as $fileObject) {
      $fileName = basename($fileObject->path);
      $fileSize = $fileObject->size;
      $fullFileName = $fileObject->path;
      echo('          <li class="fileListItem"><span class="fileImage">&nbsp;</span><span class="fileName">' .
                          $fileName . '</span><span class="fileSize">' . $fileSize . "</span></li>\n");
  }
?>
        </ul>
<?php else : ?>
        <p>You do not have any files in your [APP] Dropbox.</p>
<?php endif; ?>
      </div>
      <div class="debug">
<?php
  var_dump($metaData);
?>
      </div>
    </div>
  </body>
</html>

Oh, I originally had code to show only the PDF files, but thats not hard, just look at the 'metaData()' information. This is shown in the debug-part. If you remove the display: none; line under .debug in the CSS, you will see what $dropbox->metaData() returns. Anyway, that is the reason there is a PDF-icon for every file (which you probably won't see as you do not have an images directory). Note that there is a method in the API to get a thumbnail for a file!

I know, a way too big example with way too much styling and HTML, but you will see it is quite easy actually.

from dropbox.

jeffreyflukman avatar jeffreyflukman commented on August 15, 2024

Hi @Caster ..!
Thx so much for your example here.. it's really helpful..

from dropbox.

Caster avatar Caster commented on August 15, 2024

Hi @jeffreyflukman,

If it solves your issue you can mark the issue as closed. If you would like to see some more examples, please ask. Also don't forget to check out the examples provided by @benthedesigner!

from dropbox.

BenExile avatar BenExile commented on August 15, 2024

Hi @Caster

Thanks for picking this one up and helping @jeffreyflukman resolve his issue. Much appreciated.

from dropbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.