-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path6-assembly-with-timeout.php
42 lines (37 loc) · 1.17 KB
/
6-assembly-with-timeout.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
<?php
require __DIR__ . '/common/loader.php';
use transloadit\Transloadit;
$transloadit = new Transloadit([
'key' => getenv('MY_TRANSLOADIT_KEY'),
'secret' => getenv('MY_TRANSLOADIT_SECRET'),
]);
$response = $transloadit->createAssembly([
'files' => [dirname(__FILE__) . '/fixture/straw-apple.jpg'],
'curlOptions' => [
CURLOPT_TIMEOUT_MS => 1,
// We can't finish in the specified: '1ms' so we expect this example
// to fail with: $response->curlErrorNumber === 28
//
// You can pass any curl option here that your PHP/curl version supports:
// https://www.php.net/manual/en/function.curl-setopt.php
// Note that if you are interested in timeouts, perhaps also consider
// that you can set waitForCompletion to false and use the
// notify_url feature to get a webhook pingback when the Assembly is done.
],
'params' => [
'steps' => [
'resize' => [
'robot' => '/image/resize',
'width' => 200,
'height' => 100,
],
],
],
]);
// Show the results of the assembly we spawned
echo '<xmp>';
print_r([
'errcode' => $response->curlErrorNumber,
'errmsg' => $response->curlErrorMessage,
]);
echo '</xmp>';