Skip to content

Instantly share code, notes, and snippets.

@cam-gists
Created December 19, 2012 22:50
Show Gist options
  • Save cam-gists/4341298 to your computer and use it in GitHub Desktop.
Save cam-gists/4341298 to your computer and use it in GitHub Desktop.
PHP: Dropbox Utility Class
<?php
/**
* Dropbox helper Methods
*
* @author <Christopher A. Moore> cmoore@valuationvision.com, chris@camdesigns.net
* @package Dropbox API Extension
*/
class DropboxUtility
{
public $dropbox;
public $dir_exists = false;
public $meta;
function __construct($OAuth)
{
$this->dropbox = new Dropbox\API($OAuth);
}
/**
* Create Dir if not exists
*/
function dir($dir){
$view = $this->dropbox->metaData();
foreach ($view['body']->contents as $key => $value) {
if($value->is_dir && str_replace('/', '', $value->path) == $dir){
$this->dir_exists = 1;
return false;
}
}
// If the Dir does not exist create it
if(!$this->dir_exists){
$this->dropbox->create($dir);
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment