Example #1
0
<?php

require_once 'PHPUnit/Framework.php';
include '../Dropio/Api.php';
if (!isset($_ENV['DROPIO_API_KEY'])) {
    throw new Exception('Set the DROPIO_API_KEY environment variable: export DROPIO_API_KEY=xxx');
}
Dropio_Api::setKey($_ENV['DROPIO_API_KEY']);
//Make this at least 31
define('TEST_ITERATIONS', 31);
class Api_TestCase extends PHPUnit_Framework_TestCase
{
    public function testComments()
    {
        $drop = Dropio_Drop::instance()->save();
        $asset = $drop->addNote('This is a note', 'yes it is');
        $com = array();
        for ($a = 0; $a < TEST_ITERATIONS; $a++) {
            $comment = $asset->addComment(md5($a));
            $com[$comment->id] = $a;
        }
        $page = 1;
        while (($comments = $asset->getComments($page)) && $comments->getCount()) {
            foreach ($comments as $comment) {
                $i = $com[$comment->id];
                $this->assertEquals(md5($i), $comment->contents);
                $comment->contents = md5($i + 100);
                $comment->save();
            }
            $page++;
        }
Example #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());
}
Example #3
0
 /**
  * Constructor
  *
  * Call parent; load libraries, helpers, and models, clean post
  *
  * @access public
  */
 public function __construct()
 {
     parent::Controller();
     $this->load->config('fireignition');
     if ($this->config->item('fireignition_enabled') == true) {
         if (floor(phpversion()) < 5) {
             log_message('error', 'PHP 5 is required to run fireignition');
         } else {
             $this->load->library('firephp');
             $this->firephp->setOptions(array('includeLineNumbers' => true));
         }
     } else {
         $this->load->library('firephp_fake');
         $this->firephp =& $this->firephp_fake;
     }
     $this->load->library(array('Load_helpers', 'Util', 'Sanitize', 'Mail'));
     $this->load->model(array('User', 'Message', 'Group'));
     $_COOKIE = Sanitize::clean($_COOKIE);
     $this->params = $this->uri->params;
     $this->params = Sanitize::clean($this->params, array('odd_spaces' => false, 'encode' => false));
     if ($_POST) {
         $_POST = Sanitize::clean($_POST);
         $this->postData = $_POST;
     }
     if ($this->testing()) {
         $this->testingData['testing'] = true;
         $this->testingData['count'] = $this->countAllRecords();
     }
     $this->getUserData();
     if (!empty($this->userData)) {
         $this->Message->threaded = $this->userData['threading'];
     }
     if ($this->config->item('dropio_service_enabled') === TRUE && file_exists(APPPATH . 'libraries/dropio-php/Dropio/Api.php')) {
         include APPPATH . 'libraries/dropio-php/Dropio/Api.php';
         $this->dropio_api_key = $this->config->item('dropio_api_key');
         try {
             Dropio_Api::setKey($this->dropio_api_key);
             $this->dropio = new Dropio_Api();
         } catch (Dropio_Api_Exception $e) {
             echo "Error:" . $e->getMessage();
         }
         //var_dump($this->dropio->instance());
         //		exit;
     }
 }