diff --git a/src/Services/HttpService.php b/src/Services/HttpService.php index 6dba7b7..226c985 100644 --- a/src/Services/HttpService.php +++ b/src/Services/HttpService.php @@ -7,13 +7,28 @@ namespace QL\Services; +use GuzzleHttp\Cookie\CookieJar; use Jaeger\GHttp; use QL\QueryList; class HttpService { + protected static $cookieJar = null; + + public static function getCookieJar() + { + if(self::$cookieJar == null) + { + self::$cookieJar = new CookieJar(); + } + return self::$cookieJar; + } + public static function get(QueryList $ql,$url,$args = null,$otherArgs = []) { + $otherArgs = array_merge([ + 'cookies' => self::getCookieJar() + ],$otherArgs); $html = GHttp::get($url,$args,$otherArgs); $ql->setHtml($html); return $ql; @@ -21,6 +36,9 @@ class HttpService public static function post(QueryList $ql,$url,$args = null,$otherArgs = []) { + $otherArgs = array_merge([ + 'cookies' => self::getCookieJar() + ],$otherArgs); $html = GHttp::post($url,$args,$otherArgs); $ql->setHtml($html); return $ql;