-
Notifications
You must be signed in to change notification settings - Fork 25
It can be use? i download and blank show! #2
Comments
Did you follow the installation instructions? I just tried installing it as per instructions and it worked as expected. Simply install Composer, navigate to the directory your project is in, run composer require alorel/dropbox-v2-php or, if you already have a {
"require": {
"alorel/dropbox-v2-php": "^0.3"
}
} Make sure your installation meets the requirements, i.e. PHP 5.6 and newer. In the end your directory should look something like this and one of your <?php
use Alorel\Dropbox\Operation\Files\ListFolder\ListFolder;
use GuzzleHttp\Exception\ClientException;
require_once 'vendor/autoload.php';
$apikey = 'INPUT_YOUR_ACCESS_TOKEN_HERE';
$list = new ListFolder(false, $apikey);
try {
var_dump(
json_decode(
$list->raw('/path-to-folder')->getBody()->getContents(),
true
)
);
} catch (ClientException $e) {
echo $e->getMessage();
} |
Thank man Can i ask a question, should do i use v1 or v2 dropbox api for better performance, i only need upload via API of dropbox but so hard to find a simple example to upload dropbox via api. example almost by native code or library not via API. Thank again for beautiful code. :) |
It's just the way Composer works. 😉 This SDK is as close as you can get to raw API calls - all it does is wrap HTTP requests in PHP code. Have a look at the general instructions, upload and UploadSession examples and their documentation here and here. The arguments these methods receive map directly to the ones the Dropbox API expects. As for v1 vs v2, definitely go for v2 - it's newer and more actively developed, Dropbox want you to use v2, too. Let me know if you have any more questions - if not, I'll be closing the issue. |
Can you tell me how to use /save_url. i use https://github.com/Alorel/dropbox-v2-php/blob/master/examples/Raw/Files/SaveURL.md |
<?php
use Alorel\Dropbox\Operation\Files\SaveUrl\CheckJobStatus;
use Alorel\Dropbox\Operation\Files\SaveUrl\SaveURL;
use Alorel\Dropbox\Operation\Files\ListFolder\ListFolder;
use GuzzleHttp\Exception\ClientException;
$saveURL = new SaveURL();
$resp = json_decode($saveURL->raw('/google.html', 'https://www.google.com')->getBody()->getContents(), true);
if (isset($resp['async_job_id'])) {
$check = new CheckJobStatus();
do {
sleep(3); //Wait a bit
$r = json_decode($check->raw($resp['async_job_id'])->getBody()->getContents(), true);
} while (isset($r['.tag']) && $r['.tag'] == 'in_progress');
//You're done - URL saved
} else {
//You're done - URL saved
} |
Please follow the installation instructions on the Readme and look at the examples. This package requires knowledge of Composer and namespacing in PHP. Please look at how both of those are used before raising any more questions that aren't tied to this package. This package will not work if you just clone the source and try to use it. |
You'll find your answer in Composer's getting started documents. Everything works, otherwise it wouldn't have passed the unit tests on Travis-CI. <?php
use Alorel\Dropbox\Operation\Files\SaveUrl\CheckJobStatus;
use Alorel\Dropbox\Operation\Files\SaveUrl\SaveURL;
################################
# INCLUDE THE AUTOLOADER BELOW #
################################
require_once 'vendor/autoload.php';
##################
# IT'S IMPORTANT #
##################
SaveURL::setDefaultToken('Your token');
SaveURL::setDefaultAsync(false);
$saveURL = new SaveURL();
$resp = json_decode($saveURL->raw('/google.html', 'https://www.google.com')->getBody()->getContents(), true);
if (isset($resp['async_job_id'])) {
$check = new CheckJobStatus();
do {
echo 'Not saved yet - waiting for 3 seconds before checking for the job status' . PHP_EOL;
sleep(3); //Wait a bit
$r = json_decode($check->raw($resp['async_job_id'])->getBody()->getContents(), true);
} while (isset($r['.tag']) && $r['.tag'] == 'in_progress');
echo 'URL saved';
} else {
echo 'URL saved';
} |
Composer on its own won't do anything - you need to include the autoloaded as I did in the example above - that way simply referencing a class by name will be enough to automatically load the file containing that class. |
It can be use? i download and blank show!
Please help me setup and use it!
The text was updated successfully, but these errors were encountered: