/** * * @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; }
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 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 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 sendAccessTokenRequest($requestTokenUrl, $params) { $this->verifyState($_GET['state']); $curl = new \Curl\Curl(); $curl->verbose(); $curl->post($requestTokenUrl, $params); if ($curl->error) { $errorcode = $curl->error_code; $curl->close(); throw new \Exception("Something went wrong, unable to send request for token: " . $errorcode); } else { $token = $this->storeTokenData($curl->response); return $token; } }
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; }
/** * 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); }
/** * @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; }
<?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;
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; } } }
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]); } }