PHP code example of egnyte-php / egnyte

1. Go to this page and download the library: Download egnyte-php/egnyte 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/ */

    

egnyte-php / egnyte example snippets



$api_subdomain = 'something-something'; // ==> becomes something-something.egnyte.com


$oauth = new \Oauth($key, $secret, OAUTH_SIG_METHOD_HMACSHA256, OAUTH_AUTH_TYPE_FORM);
$tokenArray = $oauth->getRequestToken($api_subdomain ".egnyte.com/puboauth/token", [
  "username" => $username,
  "password" => $password,
  "grant_type" => "password"
]);

$client = new \EgnytePhp\Egnyte\Client( $api_subdomain, $tokenArray['access_token']);

$fileClient = new \EgnytePhp\Egnyte\Model\File( $client );

// OR $fileClient = new \EgnytePhp\Egnyte\Model\File( null, 'domain', 'oauth token' );

$response = $fileClient->upload('/Shared/Documents/test.txt', 'test file upload' );