github.com/artpar/rclone@v1.67.3/librclone/php/test.php (about)

     1  <?php
     2  /*
     3  Test program for librclone
     4  */
     5  
     6  include_once ( "rclone.php" );
     7  
     8  const REMOTE    = 'gdrive:/';
     9  const FOLDER    = "rcloneTest";
    10  const FILE      = "testFile.txt";
    11  
    12  $rc = new Rclone( __DIR__ . '/librclone.so' );
    13  
    14  $response = $rc->rpc( "config/listremotes", "{}" );
    15  print_r( $response );
    16  
    17  $response = $rc->rpc("operations/mkdir",
    18      json_encode( [
    19          'fs' => REMOTE,
    20          'remote'=> FOLDER
    21      ]));
    22  print_r( $response );
    23  
    24  $response = $rc->rpc("operations/list",
    25      json_encode( [
    26          'fs' => REMOTE,
    27          'remote'=> ''
    28      ]));
    29  print_r( $response );
    30  
    31  file_put_contents("./" . FILE, "Success!!!");
    32  $response = $rc->rpc("operations/copyfile",
    33      json_encode( [
    34          'srcFs' => getcwd(),
    35          'srcRemote'=> FILE,
    36          'dstFs' => REMOTE . FOLDER,
    37          'dstRemote' => FILE
    38      ]));
    39  print_r( $response );
    40  
    41  $response = $rc->rpc("operations/list",
    42      json_encode( [
    43          'fs' => REMOTE . FOLDER,
    44          'remote'=> ''
    45      ]));
    46  print_r( $response );
    47  if ( $response['output'] ) {
    48      $array = @json_decode( $response['output'], true );
    49      if ( $response['status'] == 200 && $array['list'] ?? 0 ) {
    50          $valid = $array['list'][0]['Name'] == FILE ? "SUCCESS" : "FAIL";
    51          print_r("The test seems: " . $valid . "\n");
    52      }
    53  }
    54  
    55  $rc->close();