Skip to content

Commit

Permalink
Merge pull request #4 from adityadees/curl-error
Browse files Browse the repository at this point in the history
fix curl error
  • Loading branch information
adityadees authored Jun 11, 2023
2 parents 8e24d0f + 95d1580 commit 593ef07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Exceptions/ErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public static function snimoeValueNotFound(): self
{
return new self("SNlM0e value not found in response. Check __Secure-1PSID value.");
}

public static function curlError($error): self
{
return new self("Curl error: " . $error);
}
}
7 changes: 6 additions & 1 deletion src/LaravelBard.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LaravelBard
private $reqid;
private $SNlM0e;

public function __construct($timeout = 6, $proxies = null, $session = null)
public function __construct($timeout = 60, $proxies = null, $session = null)
{
$this->proxies = $proxies;
$this->timeout = $timeout;
Expand Down Expand Up @@ -120,6 +120,11 @@ public function get_answer($input_text)
]);

$resp = curl_exec($this->session);

if (curl_errno($this->session)) {
throw ErrorException::curlError(curl_error($this->session));
}

$resp_dict = json_decode(explode("\n", $resp)[3], true)[0][2];

if ($resp_dict === null) {
Expand Down

0 comments on commit 593ef07

Please sign in to comment.