Exemple #1
0
 /**
  * Send a new request to the API.
  *
  * @param Box\View\Client $client The client instance to make requests from.
  * @param string $requestPath The path to add after the base path.
  * @param array|null $getParams Optional. An associative array of GET params
  *                              to be added to the URL.
  * @param array|null $postParams Optional. An associative array of POST
  *                               params to be sent in the body.
  * @param array|null $requestOptions Optional. An associative array of
  *                                   request options that may modify the way
  *                                   the request is made.
  *
  * @return array|string The response is pass-thru from Box\View\Request.
  * @throws Box\View\BoxViewException
  */
 protected static function request($client, $requestPath, $getParams = [], $postParams = [], $requestOptions = [])
 {
     return $client->getRequestHandler()->send(static::$path . $requestPath, $getParams, $postParams, $requestOptions);
 }
 public function testGetApiKey()
 {
     $apiKey = 'abc123';
     $client = new \Box\View\Client($apiKey);
     $this->assertEquals($apiKey, $client->getApiKey());
 }
Exemple #3
0
<?php

/**
 * Bootstrap
 */
error_reporting(E_ALL);
$exampleApiKey = 'YOUR_API_KEY';
// set the content type to plaintext if we're running this from a web browser
if (php_sapi_name() != 'cli') {
    header('Content-Type: text/plain');
}
require_once __DIR__ . '/../vendor/autoload.php';
$boxView = new Box\View\Client($exampleApiKey);
// when did this script start?
date_default_timezone_set('America/Los_Angeles');
$start = date('c');
// set a couple document variables we'll use later
$document = null;
$document2 = null;
/*
 * Example #1
 *
 * Upload a file. We're uploading a sample file by URL.
 */
echo 'Example #1 - Upload sample file by URL.' . "\n";
echo '  Uploading... ';
$sampleUrl = 'http://crocodoc.github.io/php-box-view/examples/files/sample.doc';
try {
    $document = $boxView->uploadUrl($sampleUrl, ['name' => 'Sample File']);
    echo 'success :)' . "\n";
    echo '  ID is ' . $document->id() . '.' . "\n";