当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::setParameterPost方法代码示例

本文整理汇总了PHP中Zend\Http\Client::setParameterPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setParameterPost方法的具体用法?PHP Client::setParameterPost怎么用?PHP Client::setParameterPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Http\Client的用法示例。


在下文中一共展示了Client::setParameterPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction

 /**
  * 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());
 }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:21,代码来源:YumlController.php

示例2: downloadFromJotForm

 /**
  *
  * @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;
 }
开发者ID:stevenbuehner,项目名称:import-jot-form,代码行数:33,代码来源:JotFormDownloadHelper.php

示例3: readStream

 /**
  * 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;
 }
开发者ID:modelframework,项目名称:modelframework,代码行数:32,代码来源:Wepo.php

示例4: call

 /**
  * 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;
 }
开发者ID:jlehmus,项目名称:NDL-VuFind2,代码行数:39,代码来源:Connector.php

示例5: addressFromCep

 /**
  * 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;
 }
开发者ID:braghimsistemas,项目名称:zf2lib,代码行数:36,代码来源:ByjgClient.php

示例6: setPostRut

 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);
     }
 }
开发者ID:jpablocasanueva,项目名称:pjud_v1,代码行数:35,代码来源:busquedaRut.php

示例7: callServer

 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();
 }
开发者ID:aaron4m,项目名称:zf2-mailchimp,代码行数:28,代码来源:Mailchimp.php

示例8: fetch

 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;
 }
开发者ID:kaiocesar,项目名称:sintegra-es,代码行数:8,代码来源:Scraping.php

示例9: request

 /**
  * @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;
 }
开发者ID:spalax,项目名称:eu-webchalange-download-images-api,代码行数:22,代码来源:Client.php

示例10: hit

 /**
  */
 public function hit($url, $method = "GET", $params)
 {
     $client = new Client($url);
     $client->setMethod($method);
     $client->setParameterPost($params);
     $return = $client->send();
     return $return->getContent();
 }
开发者ID:narwalsandeep,项目名称:switchcodes.com,代码行数:10,代码来源:Controller.php

示例11: testContentTypeAdditionlInfo

 /**
  * @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());
 }
开发者ID:navassouza,项目名称:zf2,代码行数:15,代码来源:CommonHttpTests.php

示例12: request

 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;
 }
开发者ID:armenio,项目名称:armenio-zf2-superlogica-module,代码行数:48,代码来源:Superlogica.php

示例13: getClient

 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;
 }
开发者ID:ahyswang,项目名称:eva-engine,代码行数:17,代码来源:Taoke.php

示例14: uploadAsset

 /**
  * 
  * @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);
     }
 }
开发者ID:narensgh,项目名称:ZF2-auth2,代码行数:23,代码来源:Asset.php

示例15: testFormDataEncodingWithMultiArrayZF7038

 /**
  * 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);
     }
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:22,代码来源:StaticTest.php


注:本文中的Zend\Http\Client::setParameterPost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。