Skip to content
This repository was archived by the owner on Jul 3, 2023. It is now read-only.

Commit 4536ddd

Browse files
authored
Merge pull request #1 from bobey/patch-1
Add an option to inject baseApiUrl
2 parents d3b12f8 + d272bf2 commit 4536ddd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

proxycrawl-api.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* Copyright ProxyCrawl
88
* Licensed under the Apache License 2.0
99
*/
10-
define('PROXYCRAWL_API_URL', 'https://api.proxycrawl.com/');
11-
1210
class ProxyCrawlAPI {
11+
12+
const PUBLIC_PROXYCRAWL_API_URL = 'https://api.proxycrawl.com/';
13+
1314
public $timeout = 30000;
1415
public $debug = false;
1516
public $advDebug = false; // Note that enabling advanced debug will include debugging information in the response possibly breaking up your code
@@ -21,8 +22,10 @@ public function __construct($options = []) {
2122
if (empty($options['token'])) {
2223
throw new Exception('You need to specify the token');
2324
}
25+
26+
$apiBaseUrl = isset($options['apiBaseUrl']) ? $options['apiBaseUrl'] : static::PUBLIC_PROXYCRAWL_API_URL;
2427
$this->options = $options;
25-
$this->endPointUrl = PROXYCRAWL_API_URL . '?token=' . $options['token'];
28+
$this->endPointUrl = $apiBaseUrl . '?token=' . $options['token'];
2629
}
2730

2831
public function get(string $url, array $options = []) {

0 commit comments

Comments
 (0)