Exemplo n.º 1
0


session_start();


$oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);

$dropbox = new Dropbox_API($oauth);

$account = $dropbox->getAccountInfo();

echo $account;


$tokens = $dropbox->getToken('*****@*****.**', 'wowpassword');

$_SESSION["oauth_tokens"]=$tokens;

$oauth->setToken($oauth_tokens);

$metaData = $dropbox->metaData();

if ($file_type = $data->mime_type !="jpeg/image") {

break;
}


 foreach ($metaData['body']->contents as $data) {
      if ($file_type = $data->mime_type !="jpeg/image") {
Exemplo n.º 2
0
<?php

if (isset($_POST['allow_access'])) {
    //modify include path to work w/ PEAR on Dreamhost
    ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . "/home/kshrine/.pear/home/kshrine/pear/php");
    $consumerKey = '';
    $consumerSecret = '';
    include 'Dropbox/autoload.php';
    $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
    $dropbox = new Dropbox_API($oauth);
    $tokens = $dropbox->getToken($_POST['email_address'], $_POST['password']);
    update_option('wpdp_token', $tokens);
    $stored_tokens = get_option('wpdp_token');
    $oauth->setToken($stored_tokens);
    $acct_info = $dropbox->getAccountInfo();
    update_option('wpdp_acct_name', $acct_info['display_name']);
}
?>
<div class="wrap">
  <h2>WP-Dropbox</h2>
  <?php 
$name_on_authorized_acct = get_option('wpdp_acct_name');
if (empty($name_on_authorized_acct)) {
    echo "<h3>No Dropbox in use.</h3>";
} else {
    echo "<h3>Using {$name_on_authorized_acct}'s Dropbox.</h3>";
}
?>


Exemplo n.º 3
0
<?php

$consumerKey = 'key';
// key
$consumerSecret = 'sercret';
// sercret
include 'vendor/dropbox-php/dropbox-php/src/Dropbox/autoload.php';
$oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);
$dropbox = new Dropbox_API($oauth);
// auth
$tokens = $dropbox->getToken('email', 'pass');
$oauth->setToken($tokens);
$h = fopen('/PATH/browserling.jpg', 'r');
// upload file
$dropbox->putFile('browserling.jpg', $h);
// put file
    echo get_string('whatisuseremail', 'dropbox', '', $CFG->dirroot . '/lib/editor/htmlarea/custom_plugins/dropbox/lang/') . '<br/><input type="text" name="useremail" id="useremail"><br/>';
    echo get_string('whatisuserpassword', 'dropbox', '', $CFG->dirroot . '/lib/editor/htmlarea/custom_plugins/dropbox/lang/') . '<br/><input type="password" name="userpassword" id="userpassword"><br/>';
    echo "<br/><input type=\"submit\" value=\"" . get_string('login', 'dropbox', '', $CFG->dirroot . '/lib/editor/htmlarea/custom_plugins/dropbox/lang/') . "\">";
    echo "</form>";
    echo "</div>";
    print_footer();
    die;
}
// If we got that far, we have a user email and password.
// Let's save it as a Cookie (for 7 days?)
setcookie('dropbox_useremail', $useremail, time() + 360);
// 86400 = 1 day
setcookie('dropbox_userpassword', $userpassword, time() + 360);
// 360 = 1 hour
try {
    $tokens = $dropbox->getToken($useremail, $userpassword);
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
    echo 'Please close this window and start again';
    setcookie('dropbox_useremail', '', time() + 360);
    // 86400 = 1 day
    setcookie('dropbox_userpassword', '', time() + 360);
    // 360 = 1 hour
}
//echo "Tokens:\n";
//print_r($tokens);
// Note that it's wise to save these tokens for re-use.
$oauth->setToken($tokens);
//echo "Account info:\n";
//print_r($dropbox->getAccountInfo());
$accountinfo = $dropbox->getAccountInfo();