Skip to content

Commit ed1af46

Browse files
authored
New method switch_to_http() added
PixLab default to HTTPS but if you are calling from a trusted network consider using clear HTTP for performance reason
1 parent 3978067 commit ed1af46

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pixlab.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Pixlab {
1212
public $blob = null; /* Raw (Binary image content) response from the Pixlab API server */
1313
public $mime = ''; /* PixLab API Server MIME type response */
1414
public $error = ''; /* Error message if $status != 200 */
15+
public $scheme = 'https://'; /* Default to HTTPS but if you are calling from a trusted network consider using clear http:// for performance reason */
1516

1617
public function __construct($key) {
1718
$this->key = $key;
@@ -22,6 +23,9 @@ public function get_status(){
2223
public function get_blob(){
2324
return $this->blob;
2425
}
26+
public function switch_to_http(){
27+
$this->scheme = 'http://';
28+
}
2529
public function get_decoded_json(){
2630
return $this->json;
2731
}
@@ -43,7 +47,7 @@ public function get($cmd,$param = []) {
4347
$cmd = basename(trim($cmd," \t/"));
4448
/* Build the query first */
4549
$param['key'] = $this->key;
46-
$request = "https://api.pixlab.io/$cmd?".http_build_query($param);
50+
$request = $this->scheme."api.pixlab.io/$cmd?".http_build_query($param);
4751
/* Make the request now */
4852
$curl = curl_init($request);
4953
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -80,7 +84,7 @@ public function post($cmd,$param = [],$file_upload = false) {
8084
return false;
8185
}
8286
$cmd = basename(trim($cmd," \t/"));
83-
$curl = curl_init("https://api.pixlab.io/$cmd?");
87+
$curl = curl_init($this->scheme."api.pixlab.io/$cmd?");
8488
curl_setopt($curl, CURLOPT_POST, true);
8589
/* Build the query first */
8690
$param['key'] = $this->key;

0 commit comments

Comments
 (0)