<?php $client = new http\Client(); $request = new http\Client\Request(); $request->setRequestUrl('http://mockbin.com/har'); $request->setRequestMethod('GET'); $request->setQuery(new http\QueryString(array('foo' => array('bar', 'baz'), 'baz' => 'abc', 'key' => 'value'))); $client->enqueue($request)->send(); $response = $client->getResponse(); echo $response->getBody();
public function getPaymentReports($date_from, $date_to) { // Create HTTP request $request = new \http\Client\Request("GET", UCS::URL_REPORTS, array('User-Agent' => UCS::USER_AGENT, 'Accept' => UCS::ACCEPT, 'Accept-Language' => UCS::ACCEPT_LANGUAGE, 'Host' => UCS::HOST, 'Cookie' => $this->getCookieHeader(), 'Referer' => UCS::URL_REPORTS, 'Upgrade-Insecure-Requests' => 1)); $request->setQuery(array('show' => 1, 'start' => $date_from->format('Y-m-d'), 'end' => $date_to->format('Y-m-d'), 'submit.x' => 6, 'submit.y' => 15, 'dates' => 'proc', 'type' => 'detail', 'page' => 1)); // Create HTTP client with appropriate TLS version $client = new \http\Client(); $client->setOptions(array("ssl" => ["version" => \http\Client\Curl\SSL_VERSION_TLSv1])); // Do the Http request $client->enqueue($request)->send(); // Get Response cookies and text $re = $client->getResponse($request); $html = $re->getBody(); // Suppress HTML parser warnings $xml_error_mode = libxml_use_internal_errors(true); // Parse HTML into DOM/XPATH objects $dom = new \DomDocument(); $dom->loadHTML($html); $xpath = new \DomXPath($dom); // Load daily reports table and construct informational objects $reports = array(); $rows = $xpath->query("//table[2]//tr[1]/td[3]/table[2]//tr"); for ($rowi = 1; $rowi < $rows->length; $rowi++) { $row = $rows->item($rowi); $cols = $row->getElementsByTagName('td'); if ($cols->length < 8) { continue; } // Construct instance from row data $report = new UCSReport($this, $cols, $xpath); array_push($reports, $report); } // Reset xml_error_mode libxml_use_internal_errors($xml_error_mode); return $reports; }