dev-master
9999999-devpCloud SDK for PHP
MIT
The Requires
- php >=5.6.0
- ext-curl *
The Development Requires
v1.0
1.0.0.0pCloud SDK for PHP
MIT
The Requires
- php >=5.6.0
- ext-curl *
The Development Requires
Wallogit.com
2017 © Pedro Peláez
pCloud SDK for PHP
A PHP library to access pCloud API, (*1)
, (*2)
### PHP 7.1.0 or higher is Required ~~~~ Likelihood Of Impact: Critical ~~~~ * The new minimum PHP version is now 7.1.0. * PHP cURL extension, (*3)
, (*4)
, (*5)
In order to use this SDK, you have to register your application in My applications., (*6)
, (*7)
, (*8)
Install Composer., (*9)
$ composer require pcloud/pcloud-php-sdk
or add the following to composer.json file, (*10)
"require": {
"pcloud/pcloud-php-sdk": "3.*"
}
, (*11)
Copy lib/ folder and include lib/autoload.php in your code, (*12)
, (*13)
The SDK uses an OAuth 2.0 access token to authorize requests to the pCloud API.
You can obtain a token using the SDK's authorization flow.
To allow the SDK to do that, find App Key, App secret and Redirect URIs in your application configuration page and add them to /example/code.php and /example/auth.php., (*14)
Note that redirect_uri is optional., (*15)
Run /example/code.php to get an authorization code and use this code in /example/auth.php. This will return access_token and locationid., (*16)
, (*17)
// Include autoload.php and set the credential file path
$access_token = "ACCESS_TOKEN";
$locationid = 1;
$pCloudApp = new pCloud\Sdk\App();
$pCloudApp->setAccessToken($access_token);
$pCloudApp->setLocationId($locationid);
// Create Folder instance
$pcloudFolder = new pCloud\Sdk\Folder($pCloudApp);
// Create new folder in root
$folderId = $pcloudFolder->create("New folder");
// Create File instance
$pcloudFile = new pCloud\Sdk\File($pCloudApp);
// Upload new file in created folder
$fileMetadata = $pcloudFile->upload("./sample.png", $folderId);
// Get folder content
$folderContent = $pcloudFolder->getContent($folderId);
$access_token = ""; $locationid = 1; $pCloudApp = new pCloud\Sdk\App(); $pCloudApp->setAccessToken($access_token); $pCloudApp->setLocationId($locationid); $method = "userinfo"; $params = array(); $request = new pCloud\Sdk\Request($pCloudApp); $response = $request->get($method, $params); // the second argument is optional
, (*18)
In version SDK version 3 the most significant changes are related to adjusting the namespaces. To easily migrate to version 3 you need to change the following:, (*19)
<?php namespace MyPhpApplication; # this use pCloud\App; // <-- Old versions # change to: use pCloud\Sdk\App; // <-- version 3. -----
The same change needs to be applied to all pCloud SDK names, pCloud\File, pCloud\Folder, ..., (*20)
In case you intanciating the classes directly, you can make the following changes:, (*21)
<?php namespace MyPhpApplication; # this $pCloudFolder = new pCloud\Folder($pCloudApp); // <-- Old versions # change to: $pCloudFolder = new pCloud\Sdk\Folder($pCloudApp); // <-- version 3. -----
In case we missed something, you can find more examples in the "example" folder., (*22)
pCloud SDK for PHP
MIT
pCloud SDK for PHP
MIT