forked from SerjPopov/cloud-mail-ru-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
30 lines (24 loc) · 749 Bytes
/
example.php
File metadata and controls
30 lines (24 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require('vendor/autoload.php');
use SergPopov\CloudMailRu\CloudMailRu;
use SergPopov\CloudMailRu\CloudMailRuException;
$username = 'username'; // учетная запись username@mail.ru
$password = 'password';
$cloud = new CloudMailRu($username, $password);
try {
$list = $cloud->login()->folderList('/');
var_dump($list);
} catch (CloudMailRuException $e) {
echo $e->getMessage();
}
$pathLocalFile = __DIR__.'/testfile.txt';
$pathFileOnCloud = '/testdir/testfile.txt';
try {
$url = $cloud->login()
->fileRemove($pathLocalFile)
->fileUpload($pathLocalFile, $pathFileOnCloud)
->filePublish($pathFileOnCloud);
var_dump($url);
} catch (CloudMailRuException $e) {
echo $e->getMessage();
}