/**
  * Redirects the user to a YUML graph drawn with the provided `dsl_text`
  *
  * @return \Zend\Http\Response
  *
  * @throws \UnexpectedValueException if the YUML service answered incorrectly
  */
 public function indexAction()
 {
     /* @var $request \Zend\Http\Request */
     $request = $this->getRequest();
     $this->httpClient->setMethod(Request::METHOD_POST);
     $this->httpClient->setParameterPost(array('dsl_text' => $request->getPost('dsl_text')));
     $response = $this->httpClient->send();
     if (!$response->isSuccess()) {
         throw new \UnexpectedValueException('HTTP Request failed');
     }
     /* @var $redirect \Zend\Mvc\Controller\Plugin\Redirect */
     $redirect = $this->plugin('redirect');
     return $redirect->toUrl('http://yuml.me/' . $response->getBody());
 }
 /**
  *
  * @param string $jotFormUrl        	
  * @throws UnableToRetrieveJotFormFile
  * @return $localFilePath
  */
 public function downloadFromJotForm($jotFormUrl, $password)
 {
     $client = new Client();
     $client->setUri($jotFormUrl);
     $client->setOptions(array('maxredirects' => 2, 'timeout' => 30));
     // Set Certification Path when https is used - does not work (yet)
     if (strpos($jotFormUrl, 'https:') === 0) {
         $client->setOptions(array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE)));
     }
     // will use temp file
     $client->setStream();
     // Password, if set
     if (!empty($password)) {
         $client->setMethod(Request::METHOD_POST);
         $client->setParameterPost(array('passKey' => $password));
     }
     $response = $client->send();
     if ($response->getStatusCode() != 200) {
         throw new UnableToRetrieveJotFormFile('Wront StatusCode: ' . $response->getStatusCode() . ' (StatusCode=200 expected)');
     }
     // Copy StreamInput
     $tmpName = tempnam('/tmp', 'jotFormReport_');
     copy($response->getStreamName(), $tmpName);
     // Add to delete late
     $this->downloads[] = $tmpName;
     return $tmpName;
 }
示例#3
0
 /**
  * Get a read-stream for a file
  *
  * @param $path
  * @return array|bool
  */
 public function readStream($path)
 {
     $headers = ['User-Agent' => 'testing/1.0', 'Accept' => 'application/json', 'X-Foo' => ['Bar', 'Baz'], 'custom' => 'cust'];
     $stream = \GuzzleHttp\Stream\Stream::factory('contents...');
     $client = new \GuzzleHttp\Client(['headers' => $headers]);
     $resource = fopen('a.gif', 'r');
     $request = $client->put($this->api_url . 'upload', ['body' => $resource]);
     prn($client, $request);
     echo $request->getBody();
     exit;
     $location = $this->applyPathPrefix($path);
     $this->client->setMethod('PUT');
     $this->client->setUri($this->api_url . 'upload');
     $this->client->setParameterPost(array_merge($this->auth_param, ['location' => $location]));
     //        $this->client
     //            //->setHeaders(['path: /usr/local....'])
     //            ->setFileUpload('todo.txt','r')
     //            ->setRawData(fopen('todo.txt','r'));
     $fp = fopen('todo.txt', "r");
     $curl = $this->client->getAdapter();
     $curl->setCurlOption(CURLOPT_PUT, 1)->setCurlOption(CURLOPT_RETURNTRANSFER, 1)->setCurlOption(CURLOPT_INFILE, $fp)->setCurlOption(CURLOPT_INFILESIZE, filesize('todo.txt'));
     //  prn($curl->setOutputStream($fp));
     $response = $this->client->send();
     prn($response->getContent(), json_decode($response->getContent()));
     exit;
 }
示例#4
0
 /**
  * Call MetaLib X-server
  *
  * @param string $operation X-Server operation
  * @param array  $params    URL Parameters
  *
  * @return mixed simpleXMLElement
  * @throws \Exception
  */
 protected function call($operation, $params)
 {
     $this->debug("Call: {$this->host}: {$operation}: " . var_export($params, true));
     // Declare UTF-8 encoding so that SimpleXML won't encode characters.
     $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><x_server_request/>');
     $op = $xml->addChild($operation);
     $this->paramsToXml($op, $params);
     $this->client->resetParameters();
     $this->client->setUri($this->host);
     $this->client->setParameterPost(['xml' => $xml->asXML()]);
     $result = $this->client->setMethod('POST')->send();
     if (!$result->isSuccess()) {
         throw new \Exception($result->getBody());
     }
     $xml = $result->getBody();
     // Remove invalid XML fields (these were encountered in record Ppro853_304965
     // from FIN05707)
     $xml = preg_replace('/<controlfield tag="   ">.*?<\\/controlfield>/', '', $xml);
     if ($xml = simplexml_load_string($xml)) {
         $errors = $xml->xpath('//local_error | //global_error');
         if (!empty($errors)) {
             if ($errors[0]->error_code == 6026) {
                 throw new \Exception('Search timed out');
             }
             throw new \Exception($errors[0]->asXML());
         }
         $result = $xml;
     }
     return $result;
 }
示例#5
0
 /**
  * Efetua consulta de cep.
  * 
  * @param type $cep
  * @return type
  * @throws Exception
  */
 public function addressFromCep($cep)
 {
     if (!file_exists(self::CONFIG_FILE)) {
         throw new Exception("Arquivo de configurações do cliente BYJG não existe");
     }
     $config = (include self::CONFIG_FILE);
     $result = array('found' => false);
     try {
         // Requisicao ao BYJG que prove base de dados gratuita para CEP
         $byJg = new Client(self::HOST);
         $byJg->setMethod(Request::METHOD_POST);
         $byJg->setParameterPost(array('httpmethod' => 'obterlogradouroauth', 'cep' => $cep, 'usuario' => $config['username'], 'senha' => $config['password']));
         $response = $byJg->send();
         if ($response->isOk()) {
             // captura resultado e organiza dados
             $body = preg_replace("/^OK\\|/", "", $response->getBody());
             // Separa as partes do CEP
             $parts = explode(", ", $body);
             if (count($parts) <= 1) {
                 throw new Exception("Resposta ByJG não pode suprir CEP como esperado");
             }
             $result['found'] = true;
             list($result['logradouro'], $result['bairro'], $result['cidade'], $result['estado'], $result['codIbge']) = $parts;
         }
     } catch (Exception $e) {
         Firephp::getInstance()->err($e->__toString());
     }
     return $result;
 }
示例#6
0
 function setPostRut($ruts)
 {
     foreach ($ruts as $rut) {
         $busqueda[] = explode('-', $rut[0]);
     }
     echo '<pre>';
     print_r($busqueda);
     echo '</pre>';
     $client = new Client('http://reca.poderjudicial.cl/', array('maxredirects' => 100, 'timeout' => 600, 'keepalive' => true));
     $headers = $client->getRequest()->getHeaders();
     $cookies = new Zend\Http\Cookies($headers);
     $client->setMethod('GET');
     $response = $client->send();
     $client->setUri('http://reca.poderjudicial.cl/RECAWEB/AtPublicoViewAccion.do?tipoMenuATP=1');
     $cookies->addCookiesFromResponse($response, $client->getUri());
     $response = $client->send();
     $client->setUri("http://reca.poderjudicial.cl/RECAWEB/AtPublicoDAction.do");
     foreach ($busqueda as $rut) {
         $parametros = array('actionViewBusqueda' => '2', 'FLG_Busqueda' => '2', 'FLG_User_Valid' => '0', 'TIP_Lengueta' => 'tdDos', 'COD_Competencia' => 'C', 'tribunal_aux' => '-1', 'username_aux' => '', 'password_aux' => '', 'aux_codlibro' => '', 'aux_rolinterno' => '', 'aux_eracausa' => '', 'aux_codcorte' => '', 'RUT_Cod_Competencia' => 'C', 'RUT_Rut' => $rut[0], 'RUT_Rut_Db' => $rut[1], 'RIT_Cod_Competencia' => '0', 'RIT_Tip_Causa' => '0', 'RIT_Rol_Interno' => '', 'RIT_Era_Causa' => '', 'corte_Cod_Tribunal' => '-1', 'corte_Cod_Libro' => '0', 'corte_Rol_Interno' => '', 'corte_Era_Causa' => '', 'OPC_Cod_Corte' => '-1', 'OPC_Cod_Tribunal' => '-1', 'username' => '', 'password' => '');
         $client->setParameterPost($parametros);
         echo '<pre>';
         print_r($parametros);
         echo '</pre>';
         $response = $client->setMethod('POST')->send();
         $data = $response->getContent();
         echo '<pre>';
         print_r($response->getContent());
         echo '</pre>';
         die;
         $rut = $rut[0] . '-' . $rut[1];
         $dom = new Query($data);
         $resultados = $dom->execute('#divRecursos tr');
         $rols = $this->busquedaRut($resultados, $rut);
     }
 }
示例#7
0
 public function callServer($method, $params)
 {
     // Get the URI and Url Elements
     $apiUrl = $this->generateUrl($method);
     $requestUri = $apiUrl['uri'];
     // Convert the params to something MC can understand
     $params = $this->processParams($params);
     $params["apikey"] = $this->getConfig('apiKey');
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setUri($requestUri);
     $request->getHeaders()->addHeaders(array('Host' => $apiUrl['host'], 'User-Agent' => 'MCAPI/' . $this->getConfig('apiVersion'), 'Content-type' => 'application/x-www-form-urlencoded'));
     $client = new Client();
     $client->setRequest($request);
     $client->setParameterPost($params);
     $result = $client->send();
     if ($result->getHeaders()->get('X-MailChimp-API-Error-Code')) {
         $error = unserialize($result->getBody());
         if (isset($error['error'])) {
             throw new MailchimpException('The mailchimp API has returned an error (' . $error['code'] . ': ' . $error['error'] . ')');
             return false;
         } else {
             throw new MailchimpException('There was an unspecified error');
             return false;
         }
     }
     return $result->getBody();
 }
示例#8
0
 public function fetch($cnpj)
 {
     $client = new Client('http://www.sintegra.es.gov.br/resultado.php');
     $client->setMethod(Request::METHOD_POST);
     $client->setParameterPost(['num_cnpj' => $cnpj, 'botao' => 'Consultar', 'num_ie' => '']);
     $response = $client->send();
     return $response;
 }
 /**
  * @param string $method
  * @param string $url
  * @param array [optional] $params
  */
 public function request($method, $url, $params = [])
 {
     $this->httpClient->setUri($this->moduleOptions->getApiUrl() . '/' . ltrim($url, '/'));
     $this->httpClient->setMethod($method);
     if (!is_null($params)) {
         if ($method == 'post' || $method == 'put') {
             $this->httpClient->setEncType(HttpClient::ENC_FORMDATA);
             $this->httpClient->setParameterPost($params);
         } else {
             $this->httpClient->setEncType(HttpClient::ENC_URLENCODED);
             $this->httpClient->setParameterGet($params);
         }
     }
     $response = $this->httpClient->send();
     $data = json_decode($response->getBody(), true);
     return $data;
 }
 /**
  */
 public function hit($url, $method = "GET", $params)
 {
     $client = new Client($url);
     $client->setMethod($method);
     $client->setParameterPost($params);
     $return = $client->send();
     return $return->getContent();
 }
示例#11
0
 /**
  * @group ZF2-78
  * @dataProvider parameterArrayProvider
  */
 public function testContentTypeAdditionlInfo($params)
 {
     $content_type = 'application/x-www-form-urlencoded; charset=UTF-8';
     $this->client->setUri($this->baseuri . 'testPostData.php');
     $this->client->setHeaders(array('Content-Type' => $content_type));
     $this->client->setMethod(\Zend\Http\Request::METHOD_POST);
     $this->client->setParameterPost($params);
     $this->client->send();
     $request = Request::fromString($this->client->getLastRawRequest());
     $this->assertEquals($content_type, $request->getHeaders()->get('Content-Type')->getFieldValue());
 }
 public function request($service, array $params = [], $method = 'POST')
 {
     $result = false;
     try {
         $url = sprintf('https://api.superlogica.net/v2/financeiro%s', $service);
         $client = new Client($url);
         $client->setAdapter(new Curl());
         $client->setMethod($method);
         $client->setOptions(['curloptions' => [CURLOPT_HEADER => false, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false]]);
         $client->setHeaders($this->authHeader);
         if (!empty($params)) {
             if ($method == 'GET') {
                 $client->setParameterGet($params);
             } else {
                 $client->setParameterPost($params);
             }
         }
         $response = $client->send();
         if ($response->isSuccess()) {
             $body = $response->getContent();
             $json = Json\Json::decode($body, 1);
             if (!empty($json[0]['status'])) {
                 if ($json[0]['status'] == '200') {
                     $result = $json;
                 }
             } else {
                 $result = $json;
             }
         }
         $isException = false;
     } catch (\Zend\Http\Exception\RuntimeException $e) {
         $isException = true;
     } catch (\Zend\Http\Client\Adapter\Exception\RuntimeException $e) {
         $isException = true;
     } catch (Json\Exception\RuntimeException $e) {
         $isException = true;
     } catch (Json\Exception\RecursionException $e2) {
         $isException = true;
     } catch (Json\Exception\InvalidArgumentException $e3) {
         $isException = true;
     } catch (Json\Exception\BadMethodCallException $e4) {
         $isException = true;
     }
     if ($isException === true) {
         //código em caso de problemas no decode
     }
     return $result;
 }
示例#13
0
 protected function getClient($url, $query, $method = 'POST')
 {
     $client = new Client();
     $client->setUri($url);
     if ($method == 'POST') {
         $client->setMethod(Request::METHOD_POST);
         if ($query) {
             $client->setParameterPost($query);
         }
     } else {
         $client->setMethod(Request::METHOD_GET);
         if ($query) {
             $client->setParameterGet($query);
         }
     }
     return $client;
 }
示例#14
0
 /**
  * 
  * @param type $assetType
  * @param type $post
  * @return boolean
  */
 public function uploadAsset($assetType, $post)
 {
     $filename = strtolower(str_replace("_", "", $post['assetType'])) . '-' . $post['uniqueId'];
     $filepath = realpath($post['Filedata']['tmp_name']);
     $finename = $post['Filedata']['name'];
     $extension = pathinfo($finename, PATHINFO_EXTENSION);
     $destination = $assetType->getPath() . '/' . $filename . "." . $extension;
     $client = new Client();
     $client->setMethod('POST');
     $client->setUri('http://imageserver.local.com/Upload.php');
     $client->setFileUpload($filepath, 'filepath');
     $client->setParameterPost(array('destination' => $destination));
     $response = $client->send();
     if ($response->isSuccess()) {
         return array('filepath' => $response->getContent(), 'filename' => $filename);
     }
 }
示例#15
0
 /**
  * Test that POST data with mutli-dimentional array is properly encoded as
  * multipart/form-data
  *
  */
 public function testFormDataEncodingWithMultiArrayZF7038()
 {
     $this->_client->setAdapter('Zend\\Http\\Client\\Adapter\\Test');
     $this->_client->setUri('http://example.com');
     $this->_client->setEncType(HTTPClient::ENC_FORMDATA);
     $this->_client->setParameterPost(array('test' => array('v0.1', 'v0.2', 'k1' => 'v1.0', 'k2' => array('v2.1', 'k2.1' => 'v2.1.0'))));
     $this->_client->setMethod('POST');
     $this->_client->send();
     $expectedLines = file(__DIR__ . '/_files/ZF7038-multipartarrayrequest.txt');
     $gotLines = explode("\n", $this->_client->getLastRawRequest());
     $this->assertEquals(count($expectedLines), count($gotLines));
     while (($expected = array_shift($expectedLines)) && ($got = array_shift($gotLines))) {
         $expected = trim($expected);
         $got = trim($got);
         $this->assertRegExp("/^{$expected}\$/", $got);
     }
 }
示例#16
0
 public function getOauthTokenFromAuthoriseGrant($params)
 {
     $client = new Client($params['sso_oauth_url'], array('maxredirects' => 0, 'timeout' => 30, 'sslcafile' => 'data/ca-bundle.pem'));
     $client->setMethod('POST');
     $client->setEncType($params['encoding_type']);
     $params = array('redirect_uri' => $params['sso_redirect_uri'], 'client_id' => $params['sso_client_id'], 'client_secret' => $params['sso_secret'], 'code' => $params['code'], 'grant_type' => $params['grant_type'], 'response_type' => $params['response_type']);
     $client->setParameterPost($params);
     $response = $client->send();
     if (!$response instanceof Response) {
         return false;
     }
     $data = json_decode($response->getBody());
     if (!isset($data->access_token) or !isset($data->expires_in) or !isset($data->token_type) or !isset($data->scope) or !isset($data->refresh_token)) {
         return ['status' => false, 'message' => 'Invalid response'];
     }
     $date = new \DateTime();
     $interval = $data->expires_in;
     $date->add(new \DateInterval('PT' . $interval . 'S'));
     return ['status' => true, 'token' => $data->access_token, 'type' => $data->token_type, 'expires' => $date, 'scope' => $data->scope, 'refresh_token' => $data->refresh_token];
 }
示例#17
0
 /**
  * @todo use POST request instead of mailing (works for dev images)
  *
  * @Event("LiveTest.Runner.Error")
  *
  * @param \Exception $e
  */
 public function handleException(\Exception $exception)
 {
     $this->exception = $exception;
     if (!$this->isUserSpace($this->exception)) {
         if ($this->sendFeedback) {
             try {
                 $feedback = array();
                 $feedback = $this->createAttachment();
                 $zend = new Client(self::PHM_API);
                 $zend->setAdapter(new Curl());
                 $zend->setParameterPost('feedback', $feedback);
                 $zend->request('POST');
                 echo "\n\n  All error related informations were sent. Thank you for helping to improve LiveTest.";
             } catch (\Exception $e) {
                 echo "\n\n  Unable to send feedback (" . $e->getMessage() . ")";
             }
         } else {
             echo "\n\n  If this error occurs again please use the --feedback argument to send all \n" . "  error related information to our team.";
         }
     }
 }
示例#18
0
 /**
  * Send a request to Mandrill. All requests are sent via HTTP POST.
  *
  * @param string $url
  * @param array  $body
  *
  * @throws Mandrill\Exception\EmptyResponseException
  * @throws Mandrill\Exception\InvalidResponseFormatException
  *
  * @return array
  */
 protected function request($url, array $body = [])
 {
     $section = explode('\\', get_called_class());
     $section = strtolower(end($section));
     $client = new Client(self::BASE_URL . $section . '/' . $url . '.json');
     $body['key'] = $this->apiKey;
     $client->setMethod(Request::METHOD_POST);
     $client->setParameterPost($body);
     $return = null;
     try {
         $response = $client->send()->getBody();
         $return = Json::decode($response);
     } catch (HttpRuntimeException $e) {
         // empty response
         throw new EmptyResponseException('Response is empty, service unavailable.');
     } catch (JsonRuntimeException $e) {
         // invalid response
         throw new InvalidResponseFormatException('Response must be in valid json format.');
     }
     return $return;
 }
 public function getCausas($dataPost)
 {
     $cliente = new \Zend\Http\Client('http://civil.poderjudicial.cl', array('maxredirects' => 100, 'timeout' => 600, 'keepalive' => true));
     $headers = $cliente->getRequest()->getHeaders();
     $cookies = new Zend\Http\Cookies($headers);
     $cliente->setMethod('GET');
     $response = $cliente->send();
     $cliente->setUri('http://civil.poderjudicial.cl/CIVILPORWEB/AtPublicoViewAccion.do?tipoMenuATP=1');
     $cookies->addCookiesFromResponse($response, $cliente->getUri());
     $response = $cliente->send();
     $cliente->setUri('http://civil.poderjudicial.cl/CIVILPORWEB/AtPublicoDAction.do');
     $cookies->addCookiesFromResponse($response, $cliente->getUri());
     foreach ($dataPost as $post) {
         $cliente->setParameterPost(array('TIP_Consulta' => '3', 'TIP_Lengueta' => 'tdCuatro', 'SeleccionL' => '0', 'TIP_Causa' => '', 'ROL_Causa' => '', 'ERA_Causa' => '', 'RUC_Era' => '', 'RUC_Tribunal' => '3', 'RUC_Numero' => '', 'RUC_Dv' => '', 'FEC_Desde' => '20/08/2015', 'FEC_Hasta' => '20/08/2015', 'SEL_Litigantes' => '0', 'RUT_Consulta' => '', 'RUT_DvConsulta' => '', 'NOM_Consulta' => $post['Nombre'], 'APE_Paterno' => $post['Apellido_paterno'], 'APE_Materno' => $post['Apellido_materno'], 'COD_Tribunal' => '', 'irAccionAtPublico' => 'Consulta'));
         $response = $cliente->setMethod('POST')->send();
         if ($response->isOk()) {
             $data = $response->getContent();
             echo '<pre>';
             print_r($data);
             echo '</pre>';
         }
     }
 }
示例#20
0
 /**
  * Send a POST request to the event's server
  *
  * @param array postParams : params want to send by post request
  */
 private function _sendRequest($postParams)
 {
     $utilities = $this->_getUtilities();
     // Make an HTTP POST request to the event's server so he can broadcast a
     // new websocket related to the new event.
     $client = new Client('http://' . $utilities::EVENTS_SERVERS_ADDRESS . ':8002');
     $client->setMethod(Request::METHOD_POST);
     // Setting POST data.
     $client->setParameterPost($postParams);
     // Send HTTP request to server.
     $response = $client->send();
 }
 /**
  * Initiate an HTTP PUT request
  * This is used to UPDATE an entity within the API
  * Specify GET params where required should additional info be required, eg Pagination tags
  * @param array $arr_request_data
  * @param array $arr_request_params - Optional, used to set get params if required
  * @return Ambigous <\FrontCore\Models\ApiRequestModel, \FrontCore\Models\ApiRequestModel>
  */
 public function performPUTRequest($arr_request_data, $arr_request_params = NULL)
 {
     if (is_object($arr_request_params) && $arr_request_params instanceof \Zend\Stdlib\ArrayObject) {
         $arr_request_params = $arr_request_params->getArrayCopy();
     }
     //end if
     //configure the client
     $client = new Client();
     $client->setMethod("PUT");
     //set data to post
     $client->setParameterPost($arr_request_data);
     //set GET params if any
     if (is_array($arr_request_params)) {
         $client->setParameterGet($arr_request_params);
     }
     //end if
     //execute
     return self::executeRequest($client);
 }
示例#22
0
 function buscaCausas($log, $tabla)
 {
     $client2 = new Client('http://civil.poderjudicial.cl', array('maxredirects' => 100, 'timeout' => 600, 'keepalive' => true));
     $headers = $client2->getRequest()->getHeaders();
     $cookies = new Zend\Http\Cookies($headers);
     $client2->setMethod('GET');
     $response = $client2->send();
     $client2->setUri('http://civil.poderjudicial.cl/CIVILPORWEB/AtPublicoViewAccion.do?tipoMenuATP=1');
     $cookies->addCookiesFromResponse($response, $client2->getUri());
     $response = $client2->send();
     if ($response->isSuccess()) {
         $post2 = $this->setPostBPR($log, $tabla);
         //$contador = 0;
         echo '<pre>POSTS: ' . count($post2) . '</pre>';
         foreach ($post2 as $busqueda2) {
             $rut_dmo = $busqueda2[0];
             $rol = explode('-', $busqueda2[1]);
             $tip_causa = $rol[0];
             $rol_causa = $rol[1];
             $era_causa = $rol[2];
             $cod_tribunal = $busqueda2[2];
             $client2->setUri('http://civil.poderjudicial.cl/CIVILPORWEB/AtPublicoDAction.do');
             $cookies->addCookiesFromResponse($response, $client2->getUri());
             $client2->setParameterPost(array('TIP_Consulta' => '1', 'TIP_Lengueta' => 'tdUno', 'SeleccionL' => '0', 'TIP_Causa' => $tip_causa, 'ROL_Causa' => $rol_causa, 'ERA_Causa' => $era_causa, 'RUC_Era' => '', 'RUC_Tribunal' => '3', 'RUC_Numero' => '', 'RUC_Dv' => '', 'FEC_Desde' => '19/10/2015', 'FEC_Hasta' => '19/10/2015', 'SEL_Litigantes' => '0', 'RUT_Consulta' => '', 'RUT_DvConsulta' => '', 'NOM_Consulta' => '', 'APE_Paterno' => '', 'APE_Materno' => '', 'COD_Tribunal' => $cod_tribunal, 'irAccionAtPublico' => 'Consulta'));
             $response = $client2->setMethod('POST')->send();
             $data = $response->getContent();
             $dom = new Query($data);
             $results = $dom->execute('#contentCellsAddTabla tr');
             $informacionCausas = $this->getCausas($results);
             $postCausas = $this->setPostCausas($informacionCausas);
             $client2->setUri("http://civil.poderjudicial.cl/CIVILPORWEB/ConsultaDetalleAtPublicoAccion.do?");
             $cookies->addCookiesFromResponse($response, $client2->getUri());
             foreach ($postCausas as $post) {
                 $client2->setParameterPost(array("TIP_Consulta" => $post['TIP_Consulta'], "TIP_Cuaderno" => $post['TIP_Cuaderno'], "CRR_IdCuaderno" => $post['CRR_IdCuaderno'], "ROL_Causa" => $post['ROL_Causa'], "TIP_Causa" => $post['TIP_Causa'], "ERA_Causa" => $post['ERA_Causa'], "COD_Tribunal" => $post['COD_Tribunal'], "TIP_Informe" => $post['TIP_Informe'] . "&"));
                 $response = $client2->setMethod('POST')->send();
                 $data = $response->getContent();
                 $dom = new Query($data);
                 $cuadernos = $dom->execute("#TablaCuadernos .comboBox option");
                 $contador = 0;
                 foreach ($cuadernos as $cuaderno) {
                     $arr_cuadernos[$contador]['nombre'] = $cuaderno->textContent;
                     $arr_cuadernos[$contador]['id'] = $cuaderno->attributes->getNamedItem('value')->textContent;
                     $contador++;
                 }
                 $detalleCausa = $dom->execute('tr');
                 $rol = $post['TIP_Causa'] . '-' . $post['ROL_Causa'] . '-' . $post['ERA_Causa'];
                 $arr_detalles = $this->infoCausas($detalleCausa, $busqueda2[1], $rut_dmo);
                 $cuaderno = $arr_cuadernos[0]['nombre'];
                 $litigantes = $dom->execute("#Litigantes table tr");
                 $arr_litigantes = $this->getLitigantes($litigantes, $busqueda2[1], $rut_dmo, $cuaderno);
                 $tribunal = $arr_detalles['tribunal'];
                 $historias = $dom->execute("#Historia tr");
                 $arr_historias = $this->getHistorias($historias, $rol, $rut_dmo, $tribunal, $cuaderno);
                 if (count($cuadernos) > 1) {
                     $documento = $dom->getDocument();
                     preg_match_all("/(TIP_Cuaderno.value.*')/", $documento, $coincidencias);
                     $arr_tips_cuadernos = $coincidencias[0];
                     preg_match_all("/(CRR_IdCuaderno.value.*)/", $documento, $crr_id);
                     $arr_crr_cuadernos = $crr_id[0];
                     $contador = 0;
                     for ($i = 1; $i < count($cuadernos); $i++) {
                         $postCuaderno[$contador]['tip'] = str_replace("TIP_Cuaderno.value   = '", "", $arr_tips_cuadernos[$i]);
                         $postCuaderno[$contador]['tip'] = str_replace("'", "", $postCuaderno[$contador]['tip']);
                         $postCuaderno[$contador]['crr'] = str_replace("CRR_IdCuaderno.value = '", "", $arr_crr_cuadernos[$i]);
                         $postCuaderno[$contador]['crr'] = str_replace("';", "", $postCuaderno[$contador]['crr']);
                         $postCuaderno[$contador]['crr'] = trim(rtrim($postCuaderno[$contador]['crr'], " "));
                         $postCuaderno[$contador]['gls'] = $arr_cuadernos[$i]['nombre'];
                         $postCuaderno[$contador]['tip_causa'] = $post['TIP_Causa'];
                         $postCuaderno[$contador]['rol_causa'] = $post['ROL_Causa'];
                         $postCuaderno[$contador]['era_causa'] = $post['ERA_Causa'];
                         $postCuaderno[$contador]['cod_tribunal'] = $post['COD_Tribunal'];
                         $contador++;
                     }
                     foreach ($postCuaderno as $cuaderno) {
                         echo '<pre>';
                         print_r($cuaderno);
                         echo '</pre>';
                         $post_parameters = array('TIP_Causa' => $cuaderno['tip_causa'], 'ROL_Causa' => $cuaderno['rol_causa'], 'ERA_Causa' => $cuaderno['era_causa'], 'COD_Tribunal' => $cuaderno['cod_tribunal'], 'TIP_Cuaderno' => $cuaderno['tip'], 'GLS_Cuaderno' => $cuaderno['gls'], 'CRR_IdCuaderno' => $cuaderno['crr'], 'TIP_Informe' => '1', 'FLG_Caratula' => '0', 'TIP_Cargo' => '2', 'COD_Corte' => '98', 'FLG_ImpresionTribunal' => '1', 'CRR_Cuaderno' => $cuaderno['crr'], 'irAccionAtPublico' => 'Ir a Cuaderno', 'FLG_Vuelta' => 'null');
                         $client2->setUri("http://civil.poderjudicial.cl/CIVILPORWEB/AtPublicoDAction.do");
                         $cookies->addCookiesFromResponse($response, $client2->getUri());
                         $client2->setParameterPost($post_parameters);
                         $response = $client2->setMethod('POST')->send();
                         $data = $response->getContent();
                         $dom = new Query($data);
                         $cuaderno = $cuaderno['gls'];
                         $tribunal = $arr_detalles['tribunal'];
                         $historias = $dom->execute("#Historia tr");
                         $arr_historias = $this->getHistorias($historias, $rol, $rut_dmo, $tribunal, $cuaderno);
                     }
                 }
             }
         }
     } else {
         echo 'ha ocurrido un problema, por favor dirigase a la pestaña de log y restaure la busuqeda desde el punto en que se detuvo el proceso';
     }
 }
示例#23
0
 */
$headers = $client->getRequest()->getHeaders();
$cookies = new Zend\Http\Cookies($headers);
$client->setMethod('GET');
$response = $client->send();
$client->setUri('http://civil.poderjudicial.cl/CIVILPORWEB/AtPublicoViewAccion.do?tipoMenuATP=1');
$cookies->addCookiesFromResponse($response, $client->getUri());
$response = $client->send();
foreach ($arreglo as $demandado) {
    echo "<pre>Se estan buscando las causas para." . $demandado['nombre'] . " " . $demandado['apPaterno'] . " " . $demandado['apMaterno'] . ", RUT: " . $demandado['rut'] . "</pre>";
    $rut = $demandado['rut'];
    echo $rut;
    $client->setUri('http://civil.poderjudicial.cl/CIVILPORWEB/AtPublicoDAction.do');
    $cookies->addCookiesFromResponse($response, $client->getUri());
    $scrap = new Scrap();
    $client->setParameterPost(array('TIP_Consulta' => '3', 'TIP_Lengueta' => 'tdCuatro', 'SeleccionL' => '0', 'TIP_Causa' => '', 'ROL_Causa' => '', 'ERA_Causa' => '', 'RUC_Era' => '', 'RUC_Tribunal' => '3', 'RUC_Numero' => '', 'RUC_Dv' => '', 'FEC_Desde' => '20/08/2015', 'FEC_Hasta' => '20/08/2015', 'SEL_Litigantes' => '0', 'RUT_Consulta' => '', 'RUT_DvConsulta' => '', 'NOM_Consulta' => $demandado['nombre'], 'APE_Paterno' => $demandado['apPaterno'], 'APE_Materno' => $demandado['apMaterno'], 'COD_Tribunal' => '0', 'irAccionAtPublico' => 'Consulta'));
    $response = $client->setMethod('POST')->send();
    if ($response->isSuccess()) {
        $data = $response->getContent();
        $dom = new Query($data);
        $results = $dom->execute('#contentCellsAddTabla tr');
        $informacionCausas = $scrap->getCausas($results);
        echo '<pre>Se encontraron: ' . count($informacionCausas) . ' causas</pre>';
        $postCausas = $scrap->setPostCausas($informacionCausas);
        $client->setUri("http://civil.poderjudicial.cl/CIVILPORWEB/ConsultaDetalleAtPublicoAccion.do?");
        $cookies->addCookiesFromResponse($response, $client->getUri());
        foreach ($postCausas as $post) {
            $client->setParameterPost(array("TIP_Consulta" => $post['TIP_Consulta'], "TIP_Cuaderno" => $post['TIP_Cuaderno'], "CRR_IdCuaderno" => $post['CRR_IdCuaderno'], "ROL_Causa" => $post['ROL_Causa'], "TIP_Causa" => $post['TIP_Causa'], "ERA_Causa" => $post['ERA_Causa'], "COD_Tribunal" => $post['COD_Tribunal'], "TIP_Informe" => $post['TIP_Informe'] . "&"));
            $response = $client->setMethod('POST')->send();
            $data = $response->getContent();
            $dom = new Query($data);
示例#24
0
 /**
  * Gets a valid OAuth2.0 access token
  *
  * @param bool $forceNewToken
  * @return string
  */
 public function getToken($forceNewToken = false)
 {
     if ($this->session->offsetExists('accessToken') && $this->session->offsetExists('expiryTime') && is_string($this->session->accessToken) && $this->session->expiryTime > time() && !$forceNewToken) {
         return $this->session->accessToken;
     }
     $code = $this->getCode();
     if ($code instanceof Response) {
         return $code;
     }
     $httpClient = new HttpClient($this->options->vendorOptions->tokenEntryUri);
     $httpClient->setMethod('POST');
     $params = array();
     foreach ($this->options->stage2->toArray() as $key => $param) {
         if ($key === 'code') {
             $param = urlencode($code);
         }
         if (empty($param)) {
             $param = $this->getDefaultParam($key);
         }
         $params[$key] = $param;
     }
     $httpClient->setParameterPost($params);
     if (is_array($this->options->vendorOptions->headers)) {
         $httpClient->setHeaders($this->options->vendorOptions->headers);
     }
     $content = $httpClient->send()->getContent();
     if ($this->options->vendorOptions->responseFormat === 'urlencode') {
         try {
             $response = Json\Decoder::decode($content);
         } catch (\Zend\Json\Exception\RuntimeException $e) {
             if ($e->getMessage() !== 'Illegal Token') {
                 throw new OAuth2Exception('Error decoding Json: ' . $e->getMessage());
             }
             parse_str($content, $response);
         }
     } else {
         $response = Json\Decoder::decode($httpClient->send()->getContent());
     }
     if ($this->isInResponse($response, 'error')) {
         $error = $this->getFromResponse($response, 'error');
         if (is_object($error) && method_exists($error, 'type') && method_exists($error, 'code') && method_exists($error, 'message')) {
             throw new OAuth2Exception("{$error->type} ({$error->code}): {$error->message}");
         } else {
             if (!is_string($error)) {
                 $error = Json\Encoder::encode($error);
             }
             throw new OAuth2Exception("Error returned from vendor: {$error}");
         }
     }
     $expires = $this->getFromResponse($response, 'expiresIn');
     $token = $this->getFromResponse($response, 'accessToken');
     $this->session->expiryTime = $expires + time();
     $this->session->accessToken = $token;
     return $token;
 }
示例#25
0
 /**
  * Performs HTTP request to given $url using given HTTP $method.
  * Send additinal query specified by variable/value array,
  * On success returns HTTP response without headers, false on failure.
  *
  * @param string $url OpenID server url
  * @param string $method HTTP request method 'GET' or 'POST'
  * @param array $params additional qwery parameters to be passed with
  * @param int &$staus HTTP status code
  *  request
  * @return mixed
  */
 protected function _httpRequest($url, $method = 'GET', array $params = array(), &$status = null)
 {
     $client = $this->_httpClient;
     if ($client === null) {
         $client = new HttpClient($url, array('maxredirects' => 4, 'timeout' => 15, 'useragent' => 'Zend_OpenId'));
     } else {
         $client->setUri($url);
     }
     $client->resetParameters();
     if ($method == Request::METHOD_POST) {
         $client->setMethod(Request::METHOD_POST);
         $client->setParameterPost($params);
     } else {
         $client->setMethod(Request::METHOD_GET);
         $client->setParameterGet($params);
     }
     try {
         $response = $client->send();
     } catch (\Exception $e) {
         $this->_setError('HTTP Request failed: ' . $e->getMessage());
         return false;
     }
     $status = $response->getStatusCode();
     $body = $response->getBody();
     if ($status == 200 || $status == 400 && !empty($body)) {
         return $body;
     } else {
         $this->_setError('Bad HTTP response');
         return false;
     }
 }
示例#26
0
 /**
  * @param bool $sendHeader
  * @param string $contentType
  *
  * @throws \Exception
  *
  * @return string
  */
 public function request($sendHeader = true, $contentType = 'gif')
 {
     if (!in_array($contentType, ['gif', 'png', 'json'])) {
         throw new Exception(sprintf('Content type "%s" is not a valid content type for this operation', $contentType));
     }
     $client = new Client();
     $client->setUri(self::URI);
     $vars = get_object_vars($this);
     $client->setParameterPost($vars);
     $client->setMethod(Request::METHOD_POST);
     $response = $client->send();
     if ($sendHeader) {
         header('content-type: image/' . $contentType);
     }
     return $response->getBody();
 }
 /**
  * Initiate an HTTP PUT request
  * This is used to UPDATE an entity within the API
  * Specify GET params where required should additional info be required, eg Pagination tags
  * @param array $arr_request_data
  * @param array $arr_request_params - Optional, used to set get params if required
  * @return Ambigous <\FrontCore\Models\ApiRequestModel, \FrontCore\Models\ApiRequestModel>
  */
 public function performPUTRequest($arr_request_data, $arr_request_params = NULL)
 {
     //configure the client
     $client = new Client();
     $client->setMethod("PUT");
     //set data to post
     $client->setParameterPost($arr_request_data);
     //set GET params if any
     if (is_array($arr_request_params)) {
         $client->setParameterGet($arr_request_params);
     }
     //end if
     //execute
     return self::executeRequest($client);
 }
示例#28
0
 /**
  * Perform a POST or PUT
  *
  * Performs a POST or PUT request. Any data provided is set in the HTTP
  * client. String data is pushed in as raw POST data; array or object data
  * is pushed in as POST parameters.
  *
  * @param mixed $method
  * @param mixed $data
  * @return Http\Response
  */
 protected function performPost($method, $data, Http\Client $client)
 {
     if (is_string($data)) {
         $client->setRawData($data);
     } elseif (is_array($data) || is_object($data)) {
         $client->setParameterPost((array) $data);
     }
     $client->setMethod($method);
     return $client->send();
 }
 /**
  * Post a solution to the verify server
  *
  * @param string $challengeField
  * @param string $responseField
  * @return \Zend\Http\Response
  * @throws \ZendService\ReCaptcha\Exception
  */
 protected function post($responseField)
 {
     if ($this->secretKey === null) {
         throw new Exception('Missing secret key');
     }
     if (empty($responseField)) {
         throw new Exception('Missing response field');
     }
     /* Fetch an instance of the http client */
     $httpClient = new HttpClient(self::VERIFY_SERVER, array('adapter' => 'Zend\\Http\\Client\\Adapter\\Socket', 'sslcapath' => '/etc/ssl/certs'));
     $postParams = array('secret' => $this->secretKey, 'response' => $responseField);
     if ($this->ip !== null) {
         $postParams['remoteip'] = $this->ip;
     }
     $httpClient->setParameterPost($postParams);
     $httpClient->setMethod(HttpRequest::METHOD_POST);
     $httpClient->setEncType($httpClient::ENC_URLENCODED);
     return $httpClient->send();
 }
示例#30
0
 public function getRestResponse($uri, $method = "GET", $params = array())
 {
     $client = new Client();
     $client->setAdapter(new Curl());
     $client->setUri($uri);
     $client->setMethod($method);
     if ($method == "GET") {
         $client->setParameterGet($params);
     } else {
         $client->setParameterPost($params);
     }
     $response = $client->send();
     return $response;
 }