function testSigleCurl() { $curl = new CurlHelper(); $curl->setOptions('http://tw.yahoo.com', function ($r) { $this->assertContains('yahoo', $r->body); $this->assertTrue(empty($r->errno)); }); $curl->process(); }
function login($cookie_file) { $data = $this->getData(); $curl = new CurlHelper(); $url = $data['URL']; $post_params = []; foreach ($data['PARAMS'] as $param) { $param[1] = str_replace(['[USER]', '[PASS]'], [$this['user'], $this['pass']], $param[1]); $post_params[$param[0]] = $param[1]; } $options = [CURLOPT_COOKIEJAR => $cookie_file, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query($post_params, '', '&')]; $curl->setOptions($url, null, $options); $curl->process(); $return = [CURLOPT_COOKIEFILE => $cookie_file]; return $return; }