@@ -24,7 +24,9 @@ require_once('conversiontools-php/src/autoload.php');
2424
2525To use REST API - get API Token from the Profile page at https://conversiontools.io/profile .
2626
27- See example ` test.php ` in the ` ./examples/ ` folder.
27+ ### Converting file
28+
29+ See example ` convert-file.php ` in the ` ./examples/ ` folder.
2830
2931``` php
3032<?php
@@ -36,13 +38,41 @@ use \ConversionTools\ConversionClient;
3638// put token here from your Profile page at https://conversiontools.io/profile
3739$token = '';
3840
39- $fileInput = 'test.xml';
41+ $fileOrUrlInput = 'test.xml';
4042$fileOutput = 'test.csv';
43+
4144$options = ['delimiter' => 'tabulation'];
4245
4346$client = new ConversionClient($token);
4447try {
45- $client->convert('convert.xml_to_csv', $fileInput, $fileOutput, $options);
48+ $client->convert('convert.xml_to_csv', $fileOrUrlInput, $fileOutput, $options);
49+ } catch (Exception $e) {
50+ print 'Exception: ' . $e->getMessage() . "\n";
51+ }
52+ ```
53+
54+ ### Converting URL
55+
56+ See example ` convert-url.php ` in the ` ./examples/ ` folder.
57+
58+ ``` php
59+ <?php
60+
61+ require_once __DIR__ . '/vendor/autoload.php';
62+
63+ use \ConversionTools\ConversionClient;
64+
65+ // put token here from your Profile page at https://conversiontools.io/profile
66+ $token = '';
67+
68+ $fileOrUrlInput = 'https://google.com';
69+ $fileOutput = 'result.pdf';
70+
71+ $options = [];
72+
73+ $client = new ConversionClient($token);
74+ try {
75+ $client->convert('convert.website_to_pdf', $fileOrUrlInput, $fileOutput, $options);
4676} catch (Exception $e) {
4777 print 'Exception: ' . $e->getMessage() . "\n";
4878}
@@ -63,15 +93,15 @@ Where `<token>` is API token from the account's Profile page https://conversiont
6393``` php
6494$client = new ConversionClient($token);
6595try {
66- $client->convert('<conversion type >', $fileInput , $fileOutput, $options);
96+ $client->convert('<conversion type >', $fileOrUrlInput , $fileOutput, $options);
6797} catch (Exception $e) {
6898 print 'Exception: ' . $e->getMessage() . "\n";
6999}
70100```
71101
72102Where
73103- ` <conversion type> ` is a specific type of conversion, from [ API Documentation] ( https://conversiontools.io/api-documentation ) .
74- - ` $fileInput ` is the filename of the input file
104+ - ` $fileOrUrlInput ` is the filename of the input file, or URL of the file to convert (when applicable)
75105- ` $fileOutput ` is the filename of the output file
76106- ` $options ` is a PHP array with options for a corresponding converter, for example:
77107``` php
@@ -90,4 +120,4 @@ List of available Conversion Types and corresponding conversion options can be f
90120
91121Licensed under [ MIT] ( ./LICENSE ) .
92122
93- Copyright (c) 2020 [ Conversion Tools] ( https://conversiontools.io )
123+ Copyright (c) 2021 [ Conversion Tools] ( https://conversiontools.io )
0 commit comments