public function testRequestReturnsOutput() { $result = $this->client->send('GET', 'http://google.com', array(), array('foo' => 'bar')); $this->assertContains('<HTML', $result); }
<?php require_once '../home/config.php'; require_once '../classes/CurlClient.php'; require_once '../classes/MyLog.php'; $db_query = new db_query('SELECT * FROM news LEFT JOIN news_detail ON new_id = ndt_id WHERE new_uploaded = 0 LIMIT 1'); $news_data = mysqli_fetch_assoc($db_query->result); if (!$news_data) { reload(3600 * 8); die('Hết tin để lấy'); } $news_data['data_picture'] = '@' . $_SERVER['DOCUMENT_ROOT'] . get_picture_path($news_data['new_picture']); $CurlClient = new CurlClient(10); $username = '******'; $password = '******'; $url_post = 'http://khang.vn/cron/get_news_local.php'; $CurlClient->setAuthenDigest($username, $password); $response = $CurlClient->post($url_post, $news_data); if ($response) { echo 'Up thành công tin ' . $response; //update tin đã upload thành công $db_ex = new db_execute('UPDATE news SET new_uploaded = 1 WHERE new_id = ' . $news_data['new_id']); } else { echo 'Lỗi'; } reload(3);
/** * gets a feed * * @param mixed $url * @param int $itemsNumber Optional, defaults to 5. * @return SimpleXMLElement the element */ private function getRSS($url, $itemsNumber = 5) { $feedKey = 'simplemvc_cache_feeds_list_' . $url; if (!$this->CacheManager->exists($feedKey)) { $client = new CurlClient(); $client->setUrl($url); $client->setReturnTransfer(); $client->setAsGet(); $feedRaw = $client->call(); $this->CacheManager->set($feedKey, $feedRaw, $this->Config['general']['rss']['ttl']); $feeds = simplexml_load_string($feedRaw); } else { $feeds = simplexml_load_string($this->CacheManager->get($feedKey)); } return $feeds; }
protected static function upload($path, $file, $body, $options, $method = 'POST') { $client = new CurlClient(); $c_file = new \CurlFile($file, null, $method == 'POST' ? 'source_video' : 'custom_poster_frame'); $c_file->setPostFilename(basename($file)); if (is_null($body)) { $body = array(); } array_push($body, $c_file); $response = $client->upload($path, $body, $options, $method); return $response; }