1. Go to this page and download the library: Download files.com/files-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
files.com / files-php-sdk example snippets
title="Example Request"
\Files\Files::setApiKey('YOUR_API_KEY');
try {
# Alternatively, you can specify the API key on a per-object basis in the second parameter to a model constructor.
$user = new \Files\Model\User($params, array('api_key' => 'YOUR_API_KEY'));
# You may also specify the API key on a per-request basis in the final parameter to static methods.
\Files\Model\User::find($id, $params, array('api_key' => 'YOUR_API_KEY'));
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}
title="Example Request"
## You may set the returned session ID to be used by default for subsequent requests.
\Files\Files::setSessionId($session->id);
try {
# Alternatively, you can specify the session ID on a per-object basis in the second parameter to a model constructor.
$user = new \Files\Model\User($params, array('session_id' => $session->id));
# You may also specify the session ID on a per-request basis in the final parameter to static methods.
\Files\Model\User::find($id, $params, array('session_id' => $session->id));
} catch (\Files\NotAuthenticated\InvalidUsernameOrPasswordException $e) {
echo 'Authentication Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
} catch (\Files\FilesException $e) {
echo 'Unknown Error Occurred (' . get_class($e) . '): ', $e->getMessage(), "\n";
}