public function query() { $url = 'http://m.kuaidi100.com/query'; $url .= '?type=' . $this->type . '&postid=' . $this->postId; $url .= '&id=' . $this->id . '&valicode=' . $this->validateCode; $url .= '&temp=' . $this->temp; $referer = 'http://m.kuaidi100.com/index_all.html'; $curl = new \Curl\Curl(); $curl->setUserAgent($_SERVER['HTTP_USER_AGENT']); $curl->setReferrer($referer); $curl->setOpt(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); $curl->post($url); if ($curl->error) { $response = array('errno' => $curl->error_code, 'message' => $curl->error_message); } else { $data = json_decode($curl->response); if ($data->status == 200) { $response = array('errno' => 0, 'data' => $data); } else { throw new \Exception($data->message, $data->status); } } $curl->close(); return $response; }
public function testAddCurl() { $curl = new Curl\Curl(); $curl->setUrl(Test::TEST_URL); $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET'); $curl->setOpt(CURLOPT_HTTPGET, true); $multi_curl = new MultiCurl(); $multi_curl->addCurl($curl); $multi_curl->start(); }
<?php use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; Symfony\Component\Debug\ErrorHandler::register(); Symfony\Component\Debug\ExceptionHandler::register(); $curl = new Curl\Curl(); $curl->setOpt(CURLOPT_CONNECTTIMEOUT, 10); $curl->setOpt(CURLOPT_RETURNTRANSFER, true); $curl->setOpt(CURLOPT_HEADER, false); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $app['curl'] = $curl; $app['locale'] = LOCALE; $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/views')); $app['twig'] = $app->extend('twig', function (Twig_Environment $twig, $app) { $twig->addExtension(new Cocur\Slugify\Bridge\Twig\SlugifyExtension(Cocur\Slugify\Slugify::create())); if ($app['debug']) { $twig->addExtension(new Twig_Extension_Debug()); } return $twig; }); $app->register(new Silex\Provider\SessionServiceProvider()); $app->register(new Silex\Provider\ServiceControllerServiceProvider()); $app->register(new Silex\Provider\AssetServiceProvider()); if ($app['debug']) { $app->register(new Silex\Provider\VarDumperServiceProvider()); $app->register(new Silex\Provider\MonologServiceProvider(), array('monolog.logfile' => __DIR__ . '/logs/silex_dev.log')); $app->register(new Silex\Provider\HttpFragmentServiceProvider()); $app->register(new Silex\Provider\WebProfilerServiceProvider(), array('profiler.cache_dir' => __DIR__ . '/cache/profiler')); } $app->error(function (\Exception $e, Request $request, $code) use($app) {
static function check_latest() { echo "####: Initiating cURL request<br>"; $curl = new Curl\Curl(); $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false); $curl->get(upgrader::$base_url . 'news/latest.php'); if ($curl->error) { echo ' Error: ' . $curl->error_code . ': ' . $curl->error_message; } else { $arr = explode("|", $curl->response); echo "1.3> Response: <br>" . "Raw: " . $curl->response . '<br>' . "Latest version is " . $arr[0] . "<br>" . "File to be downloaded to cache dir: " . $arr[1] . "<br>"; // unset($_SESSION['codo_file_to_download']); // var_dump($_SESSION); $_SESSION['codo_file_to_download'] = trim($arr[1]); $_SESSION['codo_file_to_download_hash'] = trim($arr[2]); // $_SESSION['542d2e3195cfeA_loggedin_avatar']=22; upgrader::$latest_version = $arr[0]; if (upgrader::is_required()) { echo "1.4> Initiating Download phase 2.0...<hr>"; } else { echo " You are using the latest version :)"; } } }
<?php include 'init.php'; if (!isset($argv[1])) { die('You need to specify sleeping time as the first argument!'); } sleep($argv[1]); writeLog('info', 'Checking'); $curl = new Curl\Curl(); $curl->setOpt(CURLOPT_TIMEOUT, 5000); $curl->setHeader('Cookie', $config['cookie']); $curl->setHeader('Upgrade-Insecure-Requests', '1'); $curl->get('http://sms.tsu.ge/sms/Students/StudIndCxrili.aspx'); if ($curl->error) { writeLog('info', 'Error'); writeLog('error', $curl->error_message); die($curl->error_message); } file_put_contents(__DIR__ . '/lastResponse.txt', $curl->response); if (strpos($curl->response, $config['loggedInText']) == false) { writeLog('error', 'Cookie issue'); die('Cookie -ით შესვლა ვერ მოხერხდა' . PHP_EOL); } if (strpos($curl->response, $config['succussText']) !== false) { writeLog('info', 'Opened'); writeLastResult('on'); die('გაიხსნა!' . PHP_EOL); } writeLog('info', 'Closed'); writeLastResult('off'); echo 'ჯერ არ არის გახსნილი!' . PHP_EOL;
public static function curl() { $curl = new \Curl\Curl(); $curl->setOpt(CURLOPT_TIMEOUT, 10); return $curl; }