Exemple #1
0
 public function testDrop()
 {
     $drop = Dropio_Drop::instance()->save();
     //Should have a name of 7 or more chars, put 4 here to be safe
     $this->assertGreaterThan(4, strlen($drop->name));
     //Lets add notes
     for ($a = 0; $a < TEST_ITERATIONS; $a++) {
         $asset = $drop->addNote(sha1($a), md5($a));
         $this->assertEquals(md5($a), $asset->name);
         $this->assertEquals(sha1($a), $asset->contents);
     }
     //Test Loading a drop
     $drop2 = Dropio_Drop::load($drop->name);
     $this->assertEquals($drop2->name, $drop->name);
     $i = 0;
     $page = 1;
     while (($assets = $drop->getAssets($page)) && $assets->getCount()) {
         foreach ($assets as $name => $asset) {
             $this->assertEquals(md5($i), $asset->name);
             $this->assertEquals(sha1($i), $asset->contents);
             $i++;
         }
         $page++;
     }
     $this->assertEquals($i, TEST_ITERATIONS);
 }
Exemple #2
0
<?php

/**
 * You can execute this by running: php example.php
 * 
 * To view your changes, open: 
 *     http://drop.io/php_api_lib
 * 
 */
include 'Dropio/Api.php';
//Visit http:/api.drop.io to get an api_key.
Dropio_Api::setKey(API_KEY);
Dropio_Drop::load('php_api_lib')->addNote('This is an example of the Drop.io PHP Library', 'Hello World');
//Below is an example of a one line uploade to a drop.
Dropio_Drop::load('php_api_lib')->addFile(FILE_NAME);
//An example of looping through all the assets in a drop.
$page = 1;
while (($assets = Dropio_Drop::load('php_api_lib')->getAssets($page)) && $assets->getCount()) {
    foreach ($assets as $name => $asset) {
        echo $asset->name . '. ' . $asset->contents . "\n";
    }
    $page++;
}
// Using the Dropio_Api() class directly
try {
    $api = new Dropio_Api(API_KEY);
    $response = $api->request('GET', '/drops/php_api_lib');
    print_r($response);
} catch (Dropio_Api_Exception $e) {
    die("Error:" . $e->getMessage());
}
Exemple #3
0
 /**
  * 
  * 
  * @param string $dropname
  */
 private function loadDropioDrop($dropname = null)
 {
     if (empty($dropname)) {
         return false;
     }
     return Dropio_Drop::load($dropname);
 }