-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
48 lines (42 loc) · 991 Bytes
/
test.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* User: echo
* Date: 17/2/17
* Time: 下午6:57
*/
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/config.php';
$sdk = new \wgqi1126\YunDaMa\YunDaMa(USERNAME, PASSWORD, APP_ID, APP_KEY);
$uid = $sdk->login();
echo "uid: ";
var_dump($uid);
$balance = $sdk->balance();
echo "balance: ";
var_dump($balance);
$file = __DIR__ . '/demo.gif';
$timeout = 60;
$result = $sdk->upload($file, 4004, $timeout);
echo "upload-result: ";
var_dump($result);
if (!$result->text) {
$cid = $result->cid;
for ($i = 0; $i < $timeout; $i++) {
sleep(1);
try {
$result = $sdk->result($cid);
} catch (Exception $e) {
if ($e->getCode() == -3002) {
echo "decoding...\n";
continue;
} else {
throw $e;
}
}
echo "result: ";
var_dump($result);
if ($result->text) {
echo "Done\n";
break;
}
}
}