/** * * @return boolean */ public function sendCard() { try { $data = array('x_login' => $this->x_login, 'x_trans_key' => $this->x_trans_key, 'x_amount' => $this->x_amount, 'x_currency' => $this->x_currency, 'x_email' => $this->x_email); if (!empty($this->x_name) && !is_null($this->x_document)) { $data['x_name'] = $this->x_name; $data['x_document'] = $this->x_document; } $this->validateData($data); $data['x_control'] = $this->generateControlString(); $curl = new \Curl\Curl(); $curl->post($this->api_url, $data); if ($curl->error) { throw new CashoutCardServiceUnabailableException($curl->error_message); } $response = json_decode($curl->response); if (json_last_error() != JSON_ERROR_NONE) { throw new CashoutCardRejectedException($curl->message); } $this->validateResponseString($response); return true; } catch (CashoutCardInvalidParamException $e) { $this->r_message = $e->getMessage(); } catch (CashoutCardInvalidSignatureException $e) { $this->r_message = $e->getMessage(); } catch (CashoutCardServiceUnabailableException $e) { $this->r_message = $e->getMessage(); } catch (CashoutCardRejectedException $e) { $this->r_message = $e->getMessage(); } catch (\Exception $e) { $this->r_message = $e->getMessage(); } return false; }
protected function getData($url, $session_var = '', $cache = false) { if (!$cache || !isset($_SESSION[$session_var])) { // get events $curl = new Curl\Curl(); $curl->setHeader($this->config['auth_header_name'], $_SESSION['AUTH_TOKEN']); $curl->setHeader("Content-Type", "application/json"); $curl->get($this->config['rest_api_url'] . $url); if (!$curl->error) { $result = json_decode($curl->raw_response, true); if (is_array($result)) { $this->logger->debug("Retrieve data from { {$url} } : ", $result); } else { $this->logger->debug("Retrieve data from { {$url} } : " . $result); } $_SESSION[$session_var] = $result; return $result; } else { return null; } } else { $this->logger->debug("Get from cache { {$url} } : ", $_SESSION[$session_var]); } return $_SESSION[$session_var]; }
private function tempGetContent($url) { $curl = new \Curl\Curl(); $curl->get($url); $content = $curl->response; if (empty($content)) { return ''; } $dom = new \DOMDocument('1.0', 'utf-8'); libxml_use_internal_errors(true); $dom->loadHTML($content); libxml_clear_errors(); $dom->preserveWhiteSpace = false; // remove redundant white spaces $body = $dom->getElementsByTagName('body'); $bodyContent = null; if ($body && $body->length > 0) { // remove scripts while (($r = $dom->getElementsByTagName('script')) && $r->length) { $r->item(0)->parentNode->removeChild($r->item(0)); } $domBody = $body->item(0); $bodyContent = $dom->saveXML($domBody); //$bodyContent = $this->dom->saveHTML($this->domBody); // argument not allowed on 5.3.5 or less, see: http://www.php.net/manual/de/domdocument.savehtml.php } return $bodyContent; }
public function make_request(Request $request) { $curl = new \Curl\Curl(); $curl->setHeader('Authorization', 'Bearer ' . $this->bearerToken); $curl->setHeader('Content-Type', 'application/json'); $params = ['product_id' => 'feab4fca-ea1b-4c3d-b557-9add0f486c73', 'start_latitude' => '14.557112', 'start_longitude' => '121.018889', 'end_latitude' => '14.558607', 'end_longitude' => '121.027386']; $curl->post($this->sandbox_url . 'v1/requests', json_encode($params)); $data = json_decode($curl->response); dd($data); }
public function __construct() { echo ""; self::estatica(); include "Curl.php"; $curl = new \Curl\Curl(); $recibido = $curl->curl_download("http://www.google.com"); $resultado = $this->separar($recibido, "<title>", "</title>"); echo $resultado; }
public function renderException($exception) { if ($exception instanceof NotFoundHttpException || !$this->transferException) { return parent::renderException($exception); } $data = json_encode($this->getExceptionArray($exception)); $curl = new \Curl\Curl(); $rsp = $curl->post(Url::trailing($this->api) . 'create', ['error_json' => $data]); if (!YII_DEBUG) { return '<html><head><title>Fehler</title></head><body style="padding:40px;"><h2>Seiten Fehler</h2><p>Es ist ein unerwartet Fehler passiert, wir bitten um Entschuldigung. Bitte versuchen Sie es später erneut.</p></body></html>'; } return parent::renderException($exception); }
public function get($path) { $curl = new \Curl\Curl(); $this->getToken(); $curl->setHeader('Authorization', 'Bearer ' . $this->token); $curl->get($this->baseUrl . $path); dd($curl->response); if ($curl->error) { return $curl->error_code; } else { $response = json_decode($curl->response); 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; } }
/** * 得到模糊坐标 */ public function getPoint($area, $address, $key) { //百度地图接口:http://api.map.baidu.com/geocoder/v2/address=地址&output=输出格式类型&key=用户密钥&city=城市名 //需要4个参数:address详细地址,output格式,ak接口密匙,city城市名 //地区转换 // $areaModel = AreaModel::find($area); // $areaname = $areaModel ? $areaModel->cityname : ''; $cityModel = new AreaModel(); $areaname = $area ? $cityModel->getAreaName($area) : ''; //请求接口,返回数据 $apiUrl = 'http://api.map.baidu.com/geocoder/v2/'; $curl = new \Curl\Curl(); $curl->setHeader('X-Authorization', $key); $curl->get($apiUrl, array('address' => $address, 'output' => 'json', 'ak' => $key, 'city' => $areaname)); $response = json_decode($curl->response); $response = \App\Tools::objectToArray($response); if ($response['status'] != 0) { if ($response['status'] == 1) { echo "<script>alert('地址有误或百度地图服务器内部有变!');history.go(-1);</script>"; exit; } elseif ($response['status'] == 2) { echo "<script>alert('地区或地址有误!');history.go(-1);</script>"; exit; } elseif ($response['status'] == 3) { echo "<script>alert('权限校验失败!');history.go(-1);</script>"; exit; } elseif ($response['status'] == 4) { echo "<script>alert('配额校验失败!');history.go(-1);</script>"; exit; } elseif ($response['status'] == 5) { echo "<script>alert('百度地图密匙错误!');history.go(-1);</script>"; exit; } elseif ($response['status'] == 101) { echo "<script>alert('服务禁用!');history.go(-1);</script>"; exit; } elseif ($response['status'] == 102) { echo "<script>alert('百度地图密匙权限不足!');history.go(-1);</script>"; exit; } elseif ($response['status'] == "2xx") { echo "<script>alert('无权限!');history.go(-1);</script>"; exit; } elseif ($response['status'] == "3xx") { echo "<script>alert('配额错误!');history.go(-1);</script>"; exit; } } return $response['result']['location']; }
public function actionIndex() { $sites = []; foreach (Site::find()->all() as $site) { $sites[] = ['data' => $site->toArray(), 'remote' => $site->getRemote()]; } $curl = new \Curl\Curl(); $curl->get('https://packagist.org/packages/zephir/luya.json'); $json = Json::decode($curl->response); foreach ($json['package']['versions'] as $version => $package) { if ($version == 'dev-master') { continue; } $this->current = $package; break; } return $this->renderPartial('index', ['sites' => $sites, 'currentVersion' => $this->current]); }
protected function getAccessToken() { if (!isset($_GET['code'])) { throw new SocException('Not find "code"'); } $url = $this->getAccessUrl($_GET['code']); $query = parse_url($url); parse_str($query['query'], $params); $query_url = $query['scheme'] . '://' . $query['host'] . $query['path']; $curl = new Curl\Curl(); $resp = $curl->post($query_url, $params); if (isset($resp->error_message)) { throw new SocException($resp->error_message, $resp->code); } $this->setToken($resp->access_token); header('Location:' . $_SESSION['back_url']); exit; }
public function tryProcess() { $result = false; if (!empty($this->url)) { $curl = new \Curl\Curl(); $curl->get($this->url); if ($curl->error) { $this->_error = $curl->errorCode . ': ' . $curl->errorMessage; } else { $response = $curl->rawResponse; if (!empty($response)) { $this->_data = json_decode($response); $result = true; } } } return $result; }
public function getRemote() { $url = Url::trailing($this->url); $data = Yii::$app->cache->get($url); if ($data === false) { $curl = new \Curl\Curl(); if ($this->auth_is_enabled) { $curl->setBasicAuthentication($this->auth_user, $this->auth_pass); } $curl->get($url . 'admin/api-admin-remote?token=' . sha1($this->token)); if ($curl->error) { $data = false; } else { $data = json_decode($curl->response, true); } Yii::$app->cache->set($url, $data, 60 * 2); } return $data; }
/** * Signin with rest api to get token, or display login form. */ protected function signin() { // redirect to home if logged if ($_SESSION && $_SESSION['USER_LOGGED']) { $this->logger->debug("Redirect to home"); header("Location: /"); exit; } $data = array(); // check login if (!empty($this->postvalues)) { $curl = new Curl\Curl(); $curl->post($this->config['login_url'], array('username' => $this->postvalues['email'], 'password' => $this->postvalues['password'])); if (!$curl->error) { $token = $curl->response_headers[$this->config['auth_header_name']]; // store token in session $_SESSION['AUTH_TOKEN'] = $token; $_SESSION['USER_LOGGED'] = true; $this->logger->debug("Add token to session, USER_LOGGED = " . $_SESSION['USER_LOGGED']); $curl->close(); // redirect to home header("Location: /"); exit; } else { // treat error // TODO externalize messages switch ($curl->error_code) { case "401": $data['login_errorMessage'] = "L'email ou le mot de passe n'est pas valide"; break; default: $data['login_errorMessage'] = "Une erreur technique est survenue"; break; } $this->logger->debug("Error : code=" . $curl->error_code . ", message=" . $data['login_errorMessage']); $curl->close(); } } $view = "signin/signin.html.twig"; $this->returnView($view, $data); }
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; }
/** * @param string $title Title of the building * @param string $street Street name with house number * @param string $zip Zip code * @param string $city City of the location * @return array Array with first element the longitude and second the latitude, if available. */ function getLongLatForAddress($title, $street, $zip, $city) { if (empty($street) || empty($zip) || empty($city)) { return array('', ''); } // try to find a building entry in our cache which has the given address $entry = R::findOne('buildinggeometry', ' street = ? AND zip = ? AND city = ? ', array($street, $zip, $city)); // if entry is not already in our cache if (null == $entry) { $entry = R::dispense('buildinggeometry'); $entry->title = $title; $entry->street = $street; $entry->zip = $zip; $entry->city = $city; $entry->lng = ""; $entry->lat = ""; } // if long and lat is not set, try to get it from google if ('' == $entry->long && '' == $entry->lat) { $curl = new Curl\Curl(); // ask google for geometry information for a given address $curl->get('http://maps.googleapis.com/maps/api/geocode/json', array('address' => $street . ' ' . $zip . ' ' . $city)); // store JSON result $latLongInformation = json_decode(json_encode($curl->response), true); if (isset($latLongInformation['results'][0]['geometry']['location']['lat']) && isset($latLongInformation['results'][0]['geometry']['location']['lng'])) { $entry->lng = $latLongInformation['results'][0]['geometry']['location']['lng']; $entry->lat = $latLongInformation['results'][0]['geometry']['location']['lat']; R::store($entry); } else { echo PHP_EOL . PHP_EOL . $title; echo PHP_EOL . $street . ' ' . $zip . ' ' . $city; echo PHP_EOL . 'no lat OR long'; $entry->lng = ''; $entry->lat = ''; } } return array($entry->lng, $entry->lat); }
<?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) {
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 require 'vendor/autoload.php'; $app = new Slim\App(); $app->post('/check', function (Slim\Http\Request $request, Slim\Http\Response $response) { if ($request->getContentType() == 'application/json') { $request_params = $request->getParsedBody(); $response_params = ['success' => false, 'message' => '', 'data' => []]; if (empty($request_params)) { $response_params['message'] = 'No parameters supplied'; } else { if (!isset($request_params['url']) || empty($request_params['url'])) { $response_params['message'] = 'Image URL parameter missing'; } else { $source_url = 'http://www.nudedetect.com/'; $curl = new \Curl\Curl(); $curl->setReferrer($source_url); $curl->post($source_url . 'process.php', ['url' => $request_params['url']]); if ($curl->error) { $response_params['message'] = $curl->error_code; } else { $image_check_response = strtolower($curl->response); $curl->close(); $image_check = preg_match_all("/([0-9]+\\.[0-9]+%)<\\/h[0-9]>\\s([a-z]+)/i", $image_check_response, $image_check_data, PREG_PATTERN_ORDER); if (!$image_check) { $response_params['message'] = 'Image check failed'; } else { $response_params['data'] = ['nude' => $image_check_data[1][0], 'minimal' => $image_check_data[1][1]]; $response_params['message'] = 'Image processed successfully'; $response_params['success'] = true; }
<?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;
public static function curl() { $curl = new \Curl\Curl(); $curl->setOpt(CURLOPT_TIMEOUT, 10); return $curl; }
<?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;
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 session_start(); $code = $_GET['code']; $state = $_GET['state']; if ($state != $_SESSION['wx_state']) { echo 'error state'; return; } if (!$code) { echo 'no code'; return; } $appid = 'wx3602f3ba4c085c82'; $secret = 'e72b58b099303b5f99dd4f25975a6444'; $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$secret}&code={$code}&grant_type=authorization_code"; require_once __DIR__ . '/Curl/autoload.php'; $curl = new \Curl\Curl(); $ret = $curl->get($url); echo $ret; file_put_contents('/tmp/wx_data.log', $ret, FILE_APPEND);
public function run($method, $data = array(), $auth = false) { if ($auth) { $this->authenticate(); $data['access_token'] = $this->getToken(); } $data = http_build_query($data); $url = $this->urls['link'] . $method . '?' . $data; $curl = new Curl\Curl(); $resp = $curl->get($url); return $resp; }
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 :)"; } } }
/** * @access protected * @param Array $data * @return Curl::response */ protected function _call($data = array()) { $curl = new \Curl\Curl(); $curl->post("https://dashboard.kukua.cc/api/sensordata/get", $data); return $curl->response; }
public function postIndex(Request $request) { $file = \App\MeterFile::where('active', 1)->first(); if (!$file) { return redirect('/')->withErrors('Данные на загружены, обратитесь Вашу Управляющую организацию.'); } $this->validate($request, ['street' => 'required|exists:streets,id', 'building' => 'required|exists:buildings,id', 'apartment' => 'required|exists:apartments,id', 'ls' => 'required|integer', 'space' => 'required|numeric', 'g-recaptcha-response' => 'required'], ['street.required' => 'Укажите улицу.', 'street.exists' => 'Вы указали неверную улицу.', 'building.required' => 'Укажите номер дома.', 'building.exists' => 'Вы указали неверный номер дома.', 'apartment.required' => 'Укажите номер квартиры.', 'apartment.exists' => 'Вы указали неверный номер квартиры.', 'ls.required' => 'Укажите лицевой счет.', 'ls.integer' => 'Лицевой счет это целое число.', 'space.required' => 'Укажите площадь помещения.', 'space.numeric' => 'Площадь помещение должно быть числом.', 'g-recaptcha-response.required' => 'Нажмите на флажок подтверждения, что Вы не робот.']); $curl = new \Curl\Curl(); $curl->post('https://www.google.com/recaptcha/api/siteverify', ['secret' => env('RECAPTHCA_SECRET'), 'response' => $request->input('g-recaptcha-response')]); $response = $curl->response; if (!isset($response->success)) { return redirect('/')->withErrors('Ошибка recaptcha, попробуйте еще раз.'); } if (!$response->success) { return redirect('/')->withErrors('Ошибка recaptcha, попробуйте еще раз.'); } $apartment = \App\Apartment::find($request->input('apartment')); if ($apartment->ls != $request->input('ls')) { return redirect('/')->withErrors('Неверно указан лицевой счет.')->withInputs(); } $space = str_replace(',', '.', $request->input('space')); if ($apartment->space != $request->input('space')) { return redirect('/')->withErrors('Неверно указана площадь.')->withInputs(); } if ($request->input('remember', false)) { return redirect('open')->with('client', ['file' => $file->id, 'ls' => $apartment->ls, 'apartment_id' => $apartment->id])->withCookie('kvowner', $request->input('ls') . ':' . $request->input('space') . ':' . $file->id, 60 * 24 * 30 * 3); } else { return redirect('open')->with('client', ['file' => $file->id, 'ls' => $apartment->ls, 'apartment_id' => $apartment->id]); } }