Skip to content

Commit 3c59e01

Browse files
Switch to authorization header (#62)
1 parent 4a4ad69 commit 3c59e01

12 files changed

+37
-34
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ If you use Composer, these dependencies should be handled automatically. If you
4444

4545
### Configuration
4646

47-
You can get your secret at https://www.convertapi.com/a
47+
You can get your API credentials at https://www.convertapi.com/a
4848

4949
```php
5050
use \ConvertApi\ConvertApi;
5151

52-
ConvertApi::setApiSecret('your-api-secret');
52+
ConvertApi::setApiCredentials('your-api-secret-or-token');
5353
```
5454

5555
### File conversion

examples/conversions_chaining.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
# Short example of conversions chaining, the PDF pages extracted and saved as separated JPGs and then ZIP'ed
1010
# https://www.convertapi.com/doc/chaining

examples/convert_stream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
# Example of converting content stream to PDF
1010
# https://www.convertapi.com/txt-to-pdf

examples/convert_url_to_pdf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
# Example of converting Web Page URL to PDF file
1010
# https://www.convertapi.com/web-to-pdf

examples/convert_word_to_pdf_and_png.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
# Example of saving Word docx to PDF and to PNG
1010
# https://www.convertapi.com/docx-to-pdf

examples/create_pdf_thumbnail.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
# Example of extracting first page from PDF and then chaining conversion PDF page to JPG.
1010
# https://www.convertapi.com/pdf-to-extract

examples/error_handling.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
try {
1010
$result = ConvertApi::convert('svg', ['File' => 'files/test.docx']);

examples/retrieve_user_information.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
# Retrieve user information
1010
# https://www.convertapi.com/doc/user

examples/split_and_merge_pdf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use \ConvertApi\ConvertApi;
55

6-
# set your api secret
7-
ConvertApi::setApiSecret(getenv('CONVERT_API_SECRET'));
6+
# set your api secret or token
7+
ConvertApi::setApiCredentials(getenv('CONVERT_API_SECRET'));
88

99
# Example of extracting first and last pages from PDF and then merging them back to new PDF.
1010
# https://www.convertapi.com/pdf-to-split

lib/ConvertApi/Client.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,15 @@ private function parseResponse($response)
169169

170170
private function url($path)
171171
{
172-
return ConvertApi::$apiBase . $path . '?secret=' . ConvertApi::getApiSecret();
172+
return ConvertApi::$apiBase . $path;
173173
}
174174

175175
private function defaultHeaders()
176176
{
177-
return ['Accept: application/json'];
177+
return [
178+
'Accept: application/json',
179+
'Authorization: Bearer ' . ConvertApi::getApiCredentials(),
180+
];
178181
}
179182

180183
private function userAgent()

0 commit comments

Comments
 (0)