示例#1
0
 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 getCurl($endpoint, $data = array())
 {
     $URL = env(env('API_ENV'));
     $curl = new \Curl\Curl();
     $curl->setUserAgent('twh.22523085;BaseCamp Software;');
     $curl->setopt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $data += array('output' => 'json', 'token' => $this->token);
     $curl->get($URL . $endpoint, $data);
     if ($curl->error) {
         die("Error:" . $curl->error_code);
     } else {
         $json = json_decode($curl->response);
         return $json;
     }
 }
示例#3
0
function download($url, $store_dir)
{
    $filename = get_image_filename($url, $store_dir);
    if (file_exists($filename)) {
        return;
    }
    //存在时不下载
    $curl = new Curl\Curl();
    $curl->setHeader('X-Requested-With', 'XMLHttpRequest');
    $curl->setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:40.0) Gecko/20100101 Firefox/40.0');
    $curl->setHeader('Accept-Language', 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3');
    $curl->setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
    @mkdir($store_dir, 0755, true);
    $curl->get($url);
    $data = $curl->response;
    file_put_contents($filename, $data);
    try {
        $image = new \Eventviva\ImageResize($filename);
        $image->resizeToWidth(JS_IMG_WIDTH);
        $image->save($filename);
    } catch (Exception $e) {
    }
    return $filename;
}
<?php

//Url на который будем отправлять данные
$url = "http://www.pokerist.by/json/freerolls/filter/";
//наш "реферер"
$ref = "http://www.pokerist.by/freerolls/paroli-na-frirolly/";
//Юзерагент
$userAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0";
//Параметры которые будем отправлять.
$params_array = array("rooms" => [4], "games" => ["HOLDEM_NOLIMIT", "HOLDEM_POTLIMIT", "HOLDEM_FIXEDLIMIT"], "daysToDisplay" => 1, "payOutTypes" => [0, 1, 2], "maxPayout" => "100000", "minPayout" => "0", "isDeposited" => false, "isPassworded" => true, "isByinned" => false, "isTicketed" => false, "isOtherConditioned" => false, "isNoRestriction" => false, "isPrivate" => false);
//Формируем json
$post_json = json_encode($params_array);
//Далее работаем с курлом:посылаем данные, заголовки,сохраняем ответ...
$curl = new \Curl\Curl();
$curl->setUserAgent($userAgent);
$curl->setReferrer($ref);
$curl->setHeader("Content-Type", "application/json");
$curl->setHeader("Content-Length", strlen($post_json));
$curl->post($url, $post_json);
//Формируем переменную,которую отдадим парсеру(html_Parser.inc.php)
$curl_html_data = $curl->response;