@@ -45,8 +45,8 @@ require 'vendor/autoload.php';
4545use transloadit\Transloadit;
4646
4747$transloadit = new Transloadit([
48- 'key' => 'YOUR_TRANSLOADIT_KEY ',
49- 'secret' => 'YOUR_TRANSLOADIT_SECRET ',
48+ 'key' => 'MY_TRANSLOADIT_KEY ',
49+ 'secret' => 'MY_TRANSLOADIT_SECRET ',
5050]);
5151
5252$response = $transloadit->createAssembly([
@@ -90,8 +90,8 @@ require 'vendor/autoload.php';
9090use transloadit\Transloadit;
9191
9292$transloadit = new Transloadit([
93- 'key' => 'YOUR_TRANSLOADIT_KEY ',
94- 'secret' => 'YOUR_TRANSLOADIT_SECRET ',
93+ 'key' => 'MY_TRANSLOADIT_KEY ',
94+ 'secret' => 'MY_TRANSLOADIT_SECRET ',
9595]);
9696
9797// Check if this request is a Transloadit redirect_url notification.
@@ -139,7 +139,10 @@ To integrate Uppy with your PHP backend:
1391391 . Include Uppy in your HTML:
140140
141141``` html
142- <link href =" https://releases.transloadit.com/uppy/v3.3.1/uppy.min.css" rel =" stylesheet" >
142+ <link
143+ href =" https://releases.transloadit.com/uppy/v3.3.1/uppy.min.css"
144+ rel =" stylesheet"
145+ />
143146<script src =" https://releases.transloadit.com/uppy/v3.3.1/uppy.min.js" ></script >
144147```
145148
@@ -156,8 +159,8 @@ To integrate Uppy with your PHP backend:
156159 })
157160 .use (Uppy .Transloadit , {
158161 params: {
159- auth: { key: ' YOUR_TRANSLOADIT_KEY ' },
160- template_id: ' YOUR_TEMPLATE_ID ' ,
162+ auth: { key: ' MY_TRANSLOADIT_KEY ' },
163+ template_id: ' MY_TEMPLATE_ID ' ,
161164 notify_url: ' https://your-site.com/transloadit_notify.php'
162165 }
163166 })
@@ -179,26 +182,26 @@ require 'vendor/autoload.php';
179182use transloadit\T ransloadit;
180183
181184$transloadit = new Transloadit([
182- ' key' => ' YOUR_TRANSLOADIT_KEY ' ,
183- ' secret' => ' YOUR_TRANSLOADIT_SECRET ' ,
185+ ' key' => ' MY_TRANSLOADIT_KEY ' ,
186+ ' secret' => ' MY_TRANSLOADIT_SECRET ' ,
184187]);
185188
186189$response = Transloadit::response();
187190if ($response) {
188191 // Process the assembly result
189192 $assemblyId = $response->data[' assembly_id' ];
190193 $assemblyStatus = $response->data[' ok' ];
191-
194+
192195 // You can store the assembly information in your database
193196 // or perform any other necessary actions here
194-
197+
195198 // Log the response for debugging
196199 error_log(' Transloadit Assembly Completed: ' . $assemblyId);
197200 error_log(' Assembly Status: ' . ($assemblyStatus ? ' Success' : ' Failed' ));
198-
201+
199202 // Optionally, you can write the response to a file
200203 file_put_contents(' transloadit_response_' . $assemblyId . ' .json ' , json_encode($response->data));
201-
204+
202205 // Send a 200 OK response to Transloadit
203206 http_response_code(200);
204207 echo ' OK ' ;
@@ -221,11 +224,11 @@ You can use the `getAssembly` method to get the <dfn>Assembly</dfn> Status.
221224` ` ` php
222225< ? php
223226require ' vendor/autoload.php' ;
224- $assemblyId = ' YOUR_ASSEMBLY_ID ' ;
227+ $assemblyId = ' MY_ASSEMBLY_ID ' ;
225228
226229$transloadit = new Transloadit ([
227- ' key' => ' YOUR_TRANSLOADIT_KEY ' ,
228- ' secret' => ' YOUR_TRANSLOADIT_SECRET ' ,
230+ ' key' => ' MY_TRANSLOADIT_KEY ' ,
231+ ' secret' => ' MY_TRANSLOADIT_SECRET ' ,
229232]);
230233
231234$response = $transloadit- > getAssembly ($assemblyId);
@@ -251,14 +254,14 @@ require 'vendor/autoload.php';
251254use transloadit\Transloadit;
252255
253256$transloadit = new Transloadit ([
254- ' key' => ' YOUR_TRANSLOADIT_KEY ' ,
255- ' secret' => ' YOUR_TRANSLOADIT_SECRET ' ,
257+ ' key' => ' MY_TRANSLOADIT_KEY ' ,
258+ ' secret' => ' MY_TRANSLOADIT_SECRET ' ,
256259]);
257260
258261$response = $transloadit- > createAssembly ([
259262 ' files' => [' /PATH/TO/FILE.jpg' ],
260263 ' params' => [
261- ' template_id' => ' YOUR_TEMPLATE_ID ' ,
264+ ' template_id' => ' MY_TEMPLATE_ID ' ,
262265 ],
263266]);
264267
@@ -269,12 +272,57 @@ echo '</pre>';
269272
270273` ` `
271274
272- <!-- End of generated doc section -->
273-
274- ### Signature Auth
275+ ### Signature Auth (Assemblies)
275276
276277<dfn>Signature Authentication</dfn> is done by the PHP SDK by default internally so you do not need to worry about this :)
277278
279+ ### Signature Auth (Smart CDN)
280+
281+ You can use the ` signedSmartCDNUrl` method to generate signed URLs for Transloadit's [Smart CDN](https://transloadit.com/services/content-delivery/):
282+
283+ ` ` ` php
284+ < ? php
285+ require ' vendor/autoload.php' ;
286+
287+ use transloadit\Transloadit;
288+
289+ $transloadit = new Transloadit ([
290+ ' key' => ' MY_TRANSLOADIT_KEY' ,
291+ ' secret' => ' MY_TRANSLOADIT_SECRET' ,
292+ ]);
293+
294+ // Basic usage
295+ $url = $transloadit- > signedSmartCDNUrl (
296+ ' your-workspace-slug' ,
297+ ' your-template-slug' ,
298+ ' avatars/jane.jpg'
299+ );
300+
301+ // Advanced usage with custom parameters and expiry
302+ $url = $transloadit- > signedSmartCDNUrl (
303+ ' your-workspace-slug' ,
304+ ' your-template-slug' ,
305+ ' avatars/jane.jpg' ,
306+ [' width' => 100 , ' height' => 100 ], // Additional parameters
307+ 1732550672867 , // Expiry date in milliseconds since epoch
308+ );
309+
310+ echo $url;
311+ ` ` `
312+
313+ The generated URL will be in the format:
314+
315+ ` ` `
316+ https: // {workspace-slug}.tlcdn.com/{template-slug}/{input-field}?{query-params}&sig=sha256:{signature}
317+ ` ` `
318+
319+ Note that:
320+
321+ - The URL will expire after the specified time (default: 1 hour)
322+ - All parameters are properly encoded
323+ - The signature is generated using HMAC SHA-256
324+ - Query parameters are sorted alphabetically before signing
325+
278326## Example
279327
280328For fully working examples take a look at [` examples/ ` ](https://github.com/transloadit/php-sdk/tree/HEAD/examples).
@@ -480,7 +528,57 @@ Feel free to fork this project. We will happily merge bug fixes or other small
480528improvements. For bigger changes you should probably get in touch with us
481529before you start to avoid not seeing them merged.
482530
483- ## Versioning
531+ ### Testing
532+
533+ #### Basic Tests
534+
535+ ` ` ` bash
536+ make test
537+ ` ` `
538+
539+ #### System Tests
540+
541+ System tests require:
542+
543+ 1. Valid Transloadit credentials in environment:
544+
545+ ` ` ` bash
546+ export TRANSLOADIT_KEY = ' your-auth-key'
547+ export TRANSLOADIT_SECRET = ' your-auth-secret'
548+ ` ` `
549+
550+ Then run:
551+
552+ ` ` ` bash
553+ make test- all
554+ ` ` `
555+
556+ #### Node.js Reference Implementation Parity Assertions
557+
558+ The SDK includes assertions that compare URL signing with our reference Node.js implementation. To run these tests:
559+
560+ 1. Requirements:
561+
562+ - Node.js installed
563+ - tsx installed globally (` npm install - g tsx` )
564+
565+ 2. Install dependencies:
566+
567+ ` ` ` bash
568+ npm install - g tsx
569+ ` ` `
570+
571+ 3. Run the test:
572+
573+ ` ` ` bash
574+ export TRANSLOADIT_KEY = ' your-auth-key'
575+ export TRANSLOADIT_SECRET = ' your-auth-secret'
576+ TEST_NODE_PARITY = 1 make test- all
577+ ` ` `
578+
579+ CI opts-into ` TEST_NODE_PARITY = 1 ` , and you can optionally do this locally as well.
580+
581+ ### Versioning
484582
485583This project implements the Semantic Versioning guidelines.
486584
@@ -496,7 +594,7 @@ And constructed with the following guidelines:
496594
497595For more information on SemVer, please visit http://semver.org/.
498596
499- ## Releasing a new version
597+ ### Releasing a new version
500598
501599` ` ` bash
502600# 1. update CHANGELOG .md
0 commit comments