Created
December 19, 2012 22:50
-
-
Save cam-gists/4341298 to your computer and use it in GitHub Desktop.
PHP: Dropbox Utility Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Dropbox helper Methods | |
* | |
* @author <Christopher A. Moore> [email protected], [email protected] | |
* @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