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


PHP Client::setRawData方法代码示例

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


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

示例1: citation

 public function citation()
 {
     parent::results();
     $style = $this->request->getParam("style", false, "mla");
     $items = array();
     $results = $this->response->get("results");
     // header("Content-type: application/json");
     $x = 1;
     foreach ($results->getRecords() as $result) {
         $id = "ITEM={$x}";
         $record = $result->getXerxesRecord()->toCSL();
         $record["id"] = $id;
         $items[$id] = $record;
         $x++;
     }
     $json = json_encode(array("items" => $items));
     // header("Content-type: application/json"); echo $json; exit;
     $url = "http://127.0.0.1:8085?responseformat=html&style={$style}";
     $client = new Client();
     $client->setUri($url);
     $client->setHeaders("Content-type: application/json");
     $client->setHeaders("Expect: nothing");
     $client->setRawData($json)->setEncType('application/json');
     $response = $client->request('POST')->getBody();
     echo $response;
     exit;
 }
开发者ID:navtis,项目名称:xerxes,代码行数:27,代码来源:FolderController.php

示例2: send

 public function send()
 {
     $commands = new \Opensoft\Drools\Entity\BatchExecution('ksession1', $this->commands);
     $xml = $this->marshaller->marshalToString($commands);
     $this->logger->info("Sending to Drools: " . $xml);
     print_r($xml);
     $response = $this->httpClient->setRawData($xml, 'text/plain')->request('POST');
     if (!$response->isSuccessful()) {
         $this->logger->err($response->getHeadersAsString());
         throw new \RuntimeException("Drools Execution server returned an invalid response");
     }
     $responseXml = $response->getBody();
     if (empty($responseXml)) {
         print_r($response);
         throw new \RuntimeException("Drools Execution server returned an invalid response");
     }
     $this->logger->info("Server returned: " . $responseXml);
     print_r($responseXml);
     return $this->marshaller->unmarshalFromString($responseXml);
 }
开发者ID:KarthikRama,项目名称:phools,代码行数:20,代码来源:DroolsCommunicator.php

示例3: performHttpRequest

 /**
  * Performs a HTTP request using the specified method
  *
  * @param string $method The HTTP method for the request - 'GET', 'POST',
  *                       'PUT', 'DELETE'
  * @param string $url The URL to which this request is being performed
  * @param array $headers An associative array of HTTP headers
  *                       for this request
  * @param string $body The body of the HTTP request
  * @param string $contentType The value for the content type
  *                                of the request body
  * @param int $remainingRedirects Number of redirects to follow if request
  *                              s results in one
  * @return \Zend\Http\Response The response object
  */
 public function performHttpRequest($method, $url, $headers = null, $body = null, $contentType = null, $remainingRedirects = null)
 {
     if ($remainingRedirects === null) {
         $remainingRedirects = self::getMaxRedirects();
     }
     if ($headers === null) {
         $headers = array();
     }
     // Append a Gdata version header if protocol v2 or higher is in use.
     // (Protocol v1 does not use this header.)
     $major = $this->getMajorProtocolVersion();
     $minor = $this->getMinorProtocolVersion();
     if ($major >= 2) {
         $headers['GData-Version'] = $major + ($minor === null ? '.' + $minor : '');
     }
     // check the overridden method
     if (($method == 'POST' || $method == 'PUT') && $body === null && $headers['x-http-method-override'] != 'DELETE') {
         throw new App\InvalidArgumentException('You must specify the data to post as either a ' . 'string or a child of Zend\\GData\\App\\Entry');
     }
     if ($url === null) {
         throw new App\InvalidArgumentException('You must specify an URI to which to post.');
     }
     $headers['Content-Type'] = $contentType;
     if (self::getGzipEnabled()) {
         // some services require the word 'gzip' to be in the user-agent
         // header in addition to the accept-encoding header
         if (strpos($this->_httpClient->getHeader('User-Agent'), 'gzip') === false) {
             $headers['User-Agent'] = $this->_httpClient->getHeader('User-Agent') . ' (gzip)';
         }
         $headers['Accept-encoding'] = 'gzip, deflate';
     } else {
         $headers['Accept-encoding'] = 'identity';
     }
     // Make sure the HTTP client object is 'clean' before making a request
     // In addition to standard headers to reset via resetParameters(),
     // also reset the Slug and If-Match headers
     $this->_httpClient->resetParameters();
     $this->_httpClient->setHeaders(array('Slug', 'If-Match'));
     // Set the params for the new request to be performed
     $this->_httpClient->setHeaders($headers);
     $urlObj = new \Zend\Uri\Url($url);
     preg_match("/^(.*?)(\\?.*)?\$/", $url, $matches);
     $this->_httpClient->setUri($matches[1]);
     $queryArray = $urlObj->getQueryAsArray();
     foreach ($queryArray as $name => $value) {
         $this->_httpClient->setParameterGet($name, $value);
     }
     $this->_httpClient->setConfig(array('maxredirects' => 0));
     // Set the proper adapter if we are handling a streaming upload
     $usingMimeStream = false;
     $oldHttpAdapter = null;
     if ($body instanceof \Zend\GData\MediaMimeStream) {
         $usingMimeStream = true;
         $this->_httpClient->setRawDataStream($body, $contentType);
         $oldHttpAdapter = $this->_httpClient->getAdapter();
         if ($oldHttpAdapter instanceof \Zend\Http\Client\Adapter\Proxy) {
             $newAdapter = new HttpAdapterStreamingProxy();
         } else {
             $newAdapter = new HttpAdapterStreamingSocket();
         }
         $this->_httpClient->setAdapter($newAdapter);
     } else {
         $this->_httpClient->setRawData($body, $contentType);
     }
     try {
         $response = $this->_httpClient->request($method);
         // reset adapter
         if ($usingMimeStream) {
             $this->_httpClient->setAdapter($oldHttpAdapter);
         }
     } catch (\Zend\Http\Client\Exception $e) {
         // reset adapter
         if ($usingMimeStream) {
             $this->_httpClient->setAdapter($oldHttpAdapter);
         }
         throw new App\HttpException($e->getMessage(), $e);
     }
     if ($response->isRedirect() && $response->getStatus() != '304') {
         if ($remainingRedirects > 0) {
             $newUrl = $response->getHeader('Location');
             $response = $this->performHttpRequest($method, $newUrl, $headers, $body, $contentType, $remainingRedirects);
         } else {
             throw new App\HttpException('Number of redirects exceeds maximum', null, $response);
         }
     }
//.........这里部分代码省略.........
开发者ID:rmarshall-quibids,项目名称:zf2,代码行数:101,代码来源:App.php

示例4: secti

<?php

use Zend\Http\Client;
include 'vendor/autoload.php';
echo secti(5, 6);
$client = new Client('http://www.skalnicky-plzen.cz/kontakty.php', array('maxredirects' => 0, 'timeout' => 30));
$response = $client->send();
//var_dump($response->getBody());
$text = 'mam hlad';
//$text_v_utf8 = iconv('utf-8','cp852',$response->getBody());
$client->setRawData($text)->setEncType('text/xml')->request('POST');
开发者ID:jirkat,项目名称:praxe,代码行数:11,代码来源:index.php

示例5: performPost

 /**
  * 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();
 }
开发者ID:emus,项目名称:php-zend2-old,代码行数:21,代码来源:Twitter.php


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