From 2aa6b968586aff1a569dcb02aa24c367bf5b5fdf Mon Sep 17 00:00:00 2001 From: Pixkk <30828435+pixkk@users.noreply.github.com> Date: Thu, 13 Jul 2023 19:19:07 +0300 Subject: [PATCH 1/3] Update Bard.php Fix: From this moment we need use two cookies - __Secure-1PSID and __Secure-1PSIDTS Update: The "bl" parameter (in html code it`s cfb2h) is now obtained automatically from the html page. --- src/Bard.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Bard.php b/src/Bard.php index 4c7ace9..45c8006 100644 --- a/src/Bard.php +++ b/src/Bard.php @@ -11,6 +11,7 @@ class Bard { private $choice_id; private $reqid; private $SNlM0e; + private $cfb2h; public function __construct($timeout = 6, $proxies = null, $session = null) { $this->proxies = $proxies; @@ -31,7 +32,7 @@ public function __construct($timeout = 6, $proxies = null, $session = null) { if ($session === null) { $this->session = curl_init(); curl_setopt($this->session, CURLOPT_HTTPHEADER, $headers); - curl_setopt($this->session, CURLOPT_COOKIE, "__Secure-1PSID=" . $_ENV["_BARD_API_KEY"]); + curl_setopt($this->session, CURLOPT_COOKIE, "__Secure-1PSID=" . $_ENV["_BARD_API_KEY_1PSID"]."__Secure-1PSIDTS=" . $_ENV["_BARD_API_KEY_1PSIDTS"]); curl_setopt($this->session, CURLOPT_RETURNTRANSFER, true); } else { $this->session = $session; @@ -54,12 +55,14 @@ private function _get_snim0e() { throw new \Exception("Response Status: " . curl_getinfo($this->session, CURLINFO_HTTP_CODE)); } preg_match('/"SNlM0e":"(.*?)"/', $resp, $matches); + preg_match('/"cfb2h":"(.*?)"/', $resp, $matchesCfb2h); + $this->cfb2h = $matchesCfb2h[1]; return $matches[1]; } public function get_answer($input_text) { $params = [ - "bl" => "boq_assistant-bard-web-server_20230419.00_p1", + "bl" => $this->cfb2h, "_reqid" => (string) $this->reqid, "rt" => "c", ]; From 8a66ada759a46d379e10a22e814b344cdfb47f6a Mon Sep 17 00:00:00 2001 From: Pixkk <30828435+pixkk@users.noreply.github.com> Date: Fri, 14 Jul 2023 17:00:20 +0300 Subject: [PATCH 2/3] Update Bard.php Forgot semicolon --- src/Bard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bard.php b/src/Bard.php index 45c8006..6bab72c 100644 --- a/src/Bard.php +++ b/src/Bard.php @@ -32,7 +32,7 @@ public function __construct($timeout = 6, $proxies = null, $session = null) { if ($session === null) { $this->session = curl_init(); curl_setopt($this->session, CURLOPT_HTTPHEADER, $headers); - curl_setopt($this->session, CURLOPT_COOKIE, "__Secure-1PSID=" . $_ENV["_BARD_API_KEY_1PSID"]."__Secure-1PSIDTS=" . $_ENV["_BARD_API_KEY_1PSIDTS"]); + curl_setopt($this->session, CURLOPT_COOKIE, "__Secure-1PSID=" . $_ENV["_BARD_API_KEY_1PSID"]."; __Secure-1PSIDTS=" . $_ENV["_BARD_API_KEY_1PSIDTS"]); curl_setopt($this->session, CURLOPT_RETURNTRANSFER, true); } else { $this->session = $session; From 067865d313b798c3dc25954fd83164b481812735 Mon Sep 17 00:00:00 2001 From: John Pinto <59218902+pj8912@users.noreply.github.com> Date: Fri, 14 Jul 2023 20:20:26 +0530 Subject: [PATCH 3/3] Update Bard.php renamed `$_ENV['_BARD_API_KEY_1PSID']` and `$_ENV['_BARD_API_KEY_1PSIDTS']` to `$_ENV['BARD_API_KEY_X'] ` and `$_ENV['BARD_API_KEY_Y']` for convenience --- src/Bard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bard.php b/src/Bard.php index 6bab72c..a0fbafd 100644 --- a/src/Bard.php +++ b/src/Bard.php @@ -32,7 +32,7 @@ public function __construct($timeout = 6, $proxies = null, $session = null) { if ($session === null) { $this->session = curl_init(); curl_setopt($this->session, CURLOPT_HTTPHEADER, $headers); - curl_setopt($this->session, CURLOPT_COOKIE, "__Secure-1PSID=" . $_ENV["_BARD_API_KEY_1PSID"]."; __Secure-1PSIDTS=" . $_ENV["_BARD_API_KEY_1PSIDTS"]); + curl_setopt($this->session, CURLOPT_COOKIE, "__Secure-1PSID=" . $_ENV["BARD_API_KEY_X"]."; __Secure-1PSIDTS=" . $_ENV["BARD_API_KEY_Y"]); curl_setopt($this->session, CURLOPT_RETURNTRANSFER, true); } else { $this->session = $session;