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


PHP Zend_Http_Client::setRawData方法代码示例

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


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

示例1: sayRoom

 public function sayRoom($room, $message, $type = 'TextMessage')
 {
     $uri = 'https://' . $this->subdomain . '.campfirenow.com/room/' . $room . '/speak.json';
     $this->client->setUri($uri);
     $params['message']['type'] = $type;
     $params['message']['body'] = $message;
     $this->client->setHeaders('Content-type', 'application/json');
     $this->client->setRawData(json_encode($params));
     $this->client->setMethod(Zend_Http_Client::POST);
     $response = $this->client->request();
     return (bool) ($response->getStatus() == 200);
 }
开发者ID:hhatfield,项目名称:hermes,代码行数:12,代码来源:Bot.php

示例2: doRequest

 public function doRequest($url, $params = array())
 {
     $client = new Zend_Http_Client(trim($url), array());
     if (array_key_exists('raw', $params)) {
         $client->setRawData(json_encode($params['raw']), 'application/json');
     } else {
         $client->setParameterPost($params);
     }
     if (extension_loaded('curl')) {
         $adapter = new Zend_Http_Client_Adapter_Curl();
         $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, true);
         $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
         $client->setAdapter($adapter);
     }
     $response = $client->request('POST');
     $res = $response->getBody();
     if ($response->isError()) {
         $this->log("Request fail. Http code : " . $response->getStatus() . ' Message : ' . $res, 'ERROR');
         $this->log("Request data : " . print_r($params, 1), 'ERROR');
         if (array_key_exists('raw', $params)) {
             return $response;
         }
     }
     if (array_key_exists('raw', $params)) {
         return json_decode($res, true);
     }
     $result = null;
     parse_str($res, $result);
     return $result;
 }
开发者ID:kirchbergerknorr,项目名称:HeidelpayCD_Edition,代码行数:30,代码来源:Payment.php

示例3: testRawPostData

	/**
	 * Test using raw HTTP POST data
	 *
	 */
	public function testRawPostData() 
	{
		$data = "Chuck Norris never wet his bed as a child. The bed wet itself out of fear.";
		
		$res = $this->client->setRawData($data, 'text/html')->request('POST');
		$this->assertEquals($data, $res->getBody(), 'Response body does not contain the expected data');
	}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:11,代码来源:SocketTest.php

示例4: post

 /**
  * POST xml data to Google with authorization headers set
  *
  * @param string $xml
  * @param string $uri POST URI
  * @return Zend_Http_Response
  */
 public function post($xml, $uri = null)
 {
     if ($uri == null) {
         $uri = $this->_defaultPostUri;
     }
     if ($uri == null) {
         throw Zend::exception('Zend_Gdata_Exception', 'You must specify an URI to which to post.');
     }
     $this->_httpClient->setUri($uri);
     $this->_httpClient->setConfig(array('maxredirects' => 0));
     $this->_httpClient->setRawData($xml, 'application/atom+xml');
     $response = $this->_httpClient->request('POST');
     //set "S" cookie to avoid future redirects.
     if ($cookie = $response->getHeader('Set-cookie')) {
         list($cookieName, $cookieValue) = explode('=', $cookie, 2);
         $this->_httpClient->setCookie($cookieName, $cookieValue);
     }
     if ($response->isRedirect()) {
         //this usually happens. Re-POST with redirected URI.
         $this->_httpClient->setUri($response->getHeader('Location'));
         $this->_httpClient->setRawData($xml, 'application/atom+xml');
         $response = $this->_httpClient->request('POST');
     }
     if (!$response->isSuccessful()) {
         throw Zend::exception('Zend_Gdata_Exception', 'Post to Google failed.');
     }
     return $response;
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:35,代码来源:Gdata.php

示例5: _api_request

 protected function _api_request($method, $path, $data = null)
 {
     $url = trim($this->getBaseApiUrl(), "/") . self::API_CHECKOUT_PATH . $path;
     $client = new Zend_Http_Client($url);
     if (in_array($method, array(Zend_Http_Client::POST, Zend_Http_Client::PUT, 'PATCH')) && $data) {
         $client->setHeaders('Content-type: application/json');
         $client->setRawData(json_encode($data), 'application/json');
     }
     $client->setHeaders('Authorization: Bearer ' . Mage::getStoreConfig('payment/aplazame/secret_api_key'));
     $client->setHeaders('User-Agent: ' . self::USER_AGENT);
     $client->setHeaders('Accept: ' . 'application/vnd.aplazame' . (Mage::getStoreConfig('payment/aplazame/sandbox') ? '.sandbox-' : '-') . Mage::getStoreConfig('payment/aplazame/version') . '+json');
     $response = $client->request($method);
     $raw_result = $response->getBody();
     $status_code = $response->getStatus();
     if ($status_code >= 500) {
         Mage::throwException(Mage::helper('aplazame')->__('Aplazame error code: ' . $status_code));
     }
     try {
         $ret_json = Zend_Json::decode($raw_result, Zend_Json::TYPE_ARRAY);
     } catch (Zend_Json_Exception $e) {
         Mage::throwException(Mage::helper('aplazame')->__('Invalid api response: ' . $raw_result));
     }
     if ($status_code >= 400) {
         Mage::throwException(Mage::helper('aplazame')->__('Aplazame error code ' . $status_code . ': ' . $ret_json['error']['message']));
     }
     return $ret_json;
 }
开发者ID:jgermade,项目名称:magento,代码行数:27,代码来源:Client.php

示例6: sendAndReceive

 /**
  * @param \ShipperHQ\WS\WebServiceRequest $requestObj
  * @param $webServicePath
  * @return mixed|null
  */
 public function sendAndReceive(WebServiceRequestInterface $requestObj, $webServiceURL, $timeout = 30)
 {
     $jsonRequest = json_encode($requestObj);
     $debugRequest = $requestObj;
     $debugRequest->credentials->password = null;
     $jsonDebugRequest = json_encode($debugRequest, JSON_PRETTY_PRINT);
     $debugData['json_request'] = $jsonDebugRequest;
     $debugData['url'] = $webServiceURL;
     $responseBody = '';
     try {
         $client = new \Zend_Http_Client();
         $client->setUri($webServiceURL);
         $client->setConfig(['maxredirects' => 0, 'timeout' => $timeout]);
         $client->setRawData($jsonRequest, 'application/json');
         $response = $client->request(\Zend_Http_Client::POST);
         if (!is_null($response)) {
             $responseBody = $response->getBody();
         }
         $debugData['response'] = $responseBody;
         $responseBody = json_decode($responseBody, false);
     } catch (\Exception $e) {
         $debugData['error'] = ['error' => $e->getMessage(), 'code' => $e->getCode()];
         $debugData['response'] = '';
     }
     $result = ['result' => $responseBody, 'debug' => $debugData];
     return $result;
 }
开发者ID:shipperhq,项目名称:library-ws,代码行数:32,代码来源:WebServiceClient.php

示例7: botAction

 /**
  * CLI Bot action
  * 
  */
 public function botAction()
 {
     // Retrieve configuration
     $config = Zend_Registry::get('config');
     // URI to be called
     $uri = $config->snsServerUrlScheme . '://' . $config->snsServerUrlHost . $config->snsServerUrlPath . 'default/wikiarticle/create';
     try {
         // Connect to POP3 mail storage
         $mail = new Zend_Mail_Storage_Pop3(array('host' => $config->wikiarticle->pop3->host, 'port' => $config->wikiarticle->pop3->port, 'user' => $config->wikiarticle->pop3->user, 'password' => $config->wikiarticle->pop3->pass));
     } catch (Exception $ex) {
         //SWAT_Log::get()->MailPuller()->err($ex->getMessage());
         Zend_Registry::get('log')->err($ex->getMessage());
     }
     // Generate mail puller instance
     $puller = new SWAT_Mail_Puller();
     $puller->setFileDir(sys_get_temp_dir());
     $puller->setFileTypes(array_map('trim', explode(',', $config->wikiarticleAllowedMimeTypes)));
     //echo 'We have ' . $mail->countMessages() . ' messages to process.<br />';
     //echo 'Attachments will be stored in directory: ' . sys_get_temp_dir() . '<br />';
     // Foreach mail found
     foreach ($mail as $number => $message) {
         //echo 'Found message with title: ' . $message->subject . '<br />';
         // Check if it's a wiki article to be created
         if (strtoupper(substr($message->subject, 0, 5)) === 'WIKI:') {
             try {
                 // Retrieve message information
                 $info = $puller->getMessageInfo($message);
                 // Post found information to wiki article creator
                 $client = new Zend_Http_Client($uri);
                 $client->setRawData(Zend_Json::encode($info));
                 $response = $client->request(Zend_Http_Client::POST);
                 //echo 'Response: <pre>' . var_export($response->getBody(), true) . '</pre>';
                 // Switch to each response status
                 switch ($response->getStatus()) {
                     case 400:
                         throw new Exception('Invalid request.');
                         break;
                     case 500:
                         throw new Exception('Internal server error.');
                         break;
                     default:
                         // Decode response
                         $body = SWAT_Encoder::decode($response->getRawBody());
                         // If error code is not 201, we need to report the issue
                         if ($body['code'] != 201) {
                             throw new Exception($body['message']);
                         }
                         // Generate log entry
                         //SWAT_Log::get()->MailPuller()->debug($body['message']);
                         Zend_Registry::get('log')->debug($body['message']);
                         break;
                 }
             } catch (Exception $ex) {
                 //SWAT_Log::get()->MailPuller()->err($ex->getMessage());
                 Zend_Registry::get('log')->err($ex->getMessage());
             }
         }
         $mail->noop();
     }
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:64,代码来源:WikiarticleController.php

示例8: _call

 protected function _call($endpoint, $params = null, $method = 'GET', $data = null)
 {
     if ($params && is_array($params) && count($params) > 0) {
         $args = array();
         foreach ($params as $arg => $val) {
             $args[] = urlencode($arg) . '=' . urlencode($val);
         }
         $endpoint .= '?' . implode('&', $args);
     }
     $url = $this->_getUrl($endpoint);
     $method = strtoupper($method);
     $client = new Zend_Http_Client($url);
     $client->setMethod($method);
     $client->setHeaders(array('Accept' => 'application/json', 'Content-Type' => 'application/json'));
     $client->setAuth(Mage::getStoreConfig('zendesk/general/email') . '/token', Mage::getStoreConfig('zendesk/general/password'));
     if ($method == 'POST') {
         $client->setRawData(json_encode($data), 'application/json');
     }
     Mage::log(print_r(array('url' => $url, 'method' => $method, 'data' => json_encode($data)), true), null, 'zendesk.log');
     $response = $client->request();
     $body = json_decode($response->getBody(), true);
     Mage::log(var_export($body, true), null, 'zendesk.log');
     if ($response->isError()) {
         if (is_array($body) && isset($body['error'])) {
             if (is_array($body['error']) && isset($body['error']['title'])) {
                 throw new Exception($body['error']['title'], $response->getStatus());
             } else {
                 throw new Exception($body['error'], $response->getStatus());
             }
         } else {
             throw new Exception($body, $response->getStatus());
         }
     }
     return $body;
 }
开发者ID:drunkvegas,项目名称:done,代码行数:35,代码来源:Abstract.php

示例9: testPut

 public function testPut($record, $id, $format = 'xml')
 {
     $client = new \Zend_Http_Client(REST_URL_PUT . '/' . $id . '?format=' . $format);
     $client->setRawData(json_encode($record));
     $response = $client->request('PUT');
     print $response->getBody();
 }
开发者ID:openbizx,项目名称:openbizx-cubix,代码行数:7,代码来源:ContactRestTest.php

示例10: _request

 /**
  * 
  */
 protected function _request($url, $params, $method = Zend_Http_Client::GET)
 {
     $this->_client->setUri($url)->resetParameters();
     if (count($params['header'])) {
         foreach ($params['header'] as $name => $value) {
             $this->_client->setHeaders($name, $value);
         }
     }
     if (count($params['post'])) {
         foreach ($params['post'] as $name => $value) {
             $this->_client->setParameterPost($name, $value);
         }
     }
     if (count($params['get'])) {
         foreach ($params['get'] as $name => $value) {
             $this->_client->setParameterGet($name, $value);
         }
     }
     if (count($params['json'])) {
         //$this->_client->setHeaders('Content-type','application/json');
         $rawJson = json_encode($params['json']);
         //$this->_client->setRawData($rawJson);
         $this->_client->setRawData($rawJson, 'application/json');
     }
     $response = $this->_client->request($method);
     $result = $response->getBody();
     #echo $result . "\n\n <br>";
     return json_decode($result);
 }
开发者ID:rtsantos,项目名称:mais,代码行数:32,代码来源:Ice.php

示例11: execute

 protected function execute($arguments = array(), $options = array())
 {
     require_once realpath(dirname(__FILE__) . '/../../../../lib/vendor/OAuth/OAuth.php');
     new sfDatabaseManager($this->configuration);
     sfContext::createInstance($this->createConfiguration('pc_frontend', 'prod'), 'pc_frontend');
     $consumerKey = isset($options['consumer-key']) && $options['consumer-key'] ? $options['consumer-key'] : opOpenSocialToolKit::getOAuthConsumerKey();
     $consumer = new OAuthConsumer($consumerKey, null, null);
     $signatureMethod = new OAuthSignatureMethod_RSA_SHA1_opOpenSocialPlugin();
     $httpOptions = opOpenSocialToolKit::getHttpOptions();
     $queueGroups = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueueGroups();
     $limitRequest = (int) $options['limit-request'];
     $limitRequestApp = (int) $options['limit-request-app'];
     $allRequest = 0;
     foreach ($queueGroups as $group) {
         $application = Doctrine::getTable('Application')->find($group[0]);
         $links = $application->getLinks();
         $linkHash = array();
         foreach ($links as $link) {
             if (isset($link['rel']) && isset($link['href'])) {
                 $method = isset($link['method']) ? strtolower($link['method']) : '';
                 $method = 'post' !== $method ? 'get' : 'post';
                 $linkHash[$link['rel']] = array('href' => $link['href'], 'method' => $method);
             }
         }
         $queues = Doctrine::getTable('ApplicationLifecycleEventQueue')->getQueuesByApplicationId($group[0], $limitRequestApp);
         foreach ($queues as $queue) {
             if (!isset($linkHash[$queue->getName()])) {
                 $queue->delete();
                 continue;
             }
             $href = $linkHash[$queue->getName()]['href'];
             $method = $linkHash[$queue->getName()]['method'];
             $oauthRequest = OAuthRequest::from_consumer_and_token($consumer, null, $method, $href, $queue->getParams());
             $oauthRequest->sign_request($signatureMethod, $consumer, null);
             $client = new Zend_Http_Client();
             if ('post' !== $method) {
                 $method = 'get';
                 $client->setMethod(Zend_Http_Client::GET);
                 $href .= '?' . $oauthRequest->to_postdata();
             } else {
                 $client->setMethod(Zend_Http_Client::POST);
                 $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED);
                 $client->setRawData($oauthRequest->to_postdata());
             }
             $client->setConfig($httpOptions);
             $client->setUri($href);
             $client->setHeaders($oauthRequest->to_header());
             $response = $client->request();
             if ($response->isSuccessful()) {
                 $queue->delete();
             }
             $allRequest++;
             if ($limitRequest && $limitRequest <= $allRequest) {
                 break 2;
             }
         }
         $application->free(true);
         $queues->free(true);
     }
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:60,代码来源:opOpenSocialExecuteLifecycleEventTask.class.php

示例12: sendRequest

 protected function sendRequest($accountId, $accessToken, $body)
 {
     $client = new Zend_Http_Client();
     $client->setUri("https://api.edgecast.com/v2/mcc/customers/{$accountId}/edge/purge");
     $client->setHeaders(array('Authorization' => "TOK:{$accessToken}", 'Content-Type' => 'application/json'));
     $client->setRawData(json_encode($body));
     return $client->request(Zend_Http_Client::PUT);
 }
开发者ID:codigo5,项目名称:kasterweb-magento-cleaner,代码行数:8,代码来源:Cdn.php

示例13: fetchRequest

 public function fetchRequest(RemoteContentRequest $request)
 {
     $outHeaders = array();
     if ($request->hasHeaders()) {
         $headers = explode("\n", $request->getHeaders());
         foreach ($headers as $header) {
             if (strpos($header, ':')) {
                 $key = trim(substr($header, 0, strpos($header, ':')));
                 $val = trim(substr($header, strpos($header, ':') + 1));
                 if (strcmp($key, "User-Agent") != 0 && strcasecmp($key, "Transfer-Encoding") != 0 && strcasecmp($key, "Cache-Control") != 0 && strcasecmp($key, "Expries") != 0 && strcasecmp($key, "Content-Length") != 0) {
                     $outHeaders[$key] = $val;
                 }
             }
         }
     }
     $outHeaders['User-Agent'] = "Shindig PHP";
     $options = array();
     $options['timeout'] = Shindig_Config::get('curl_connection_timeout');
     // configure proxy
     $proxyUrl = Shindig_Config::get('proxy');
     if (!empty($proxyUrl)) {
         $options['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
         $proxy = parse_url($proxyUrl);
         if (isset($proxy['host'])) {
             $options['proxy_host'] = $proxy['host'];
         }
         if (isset($proxy['port'])) {
             $options['proxy_port'] = $proxy['port'];
         }
         if (isset($proxy['user'])) {
             $options['proxy_user'] = $proxy['user'];
         }
         if (isset($proxy['pass'])) {
             $options['proxy_pass'] = $proxy['pass'];
         }
     }
     $client = new Zend_Http_Client();
     $client->setConfig($options);
     $client->setUri($request->getUrl());
     $client->setHeaders($outHeaders);
     if ($request->getContentType()) {
         $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, $request->getContentType());
     }
     if ($request->isPost()) {
         $client->setMethod(Zend_Http_Client::POST);
         $client->setRawData($request->getPostBody());
     } else {
         $client->setMethod(Zend_Http_Client::GET);
     }
     $response = $client->request();
     $request->setHttpCode($response->getStatus());
     $request->setContentType($response->getHeader('Content-Type'));
     $request->setResponseHeaders($response->getHeaders());
     $request->setResponseContent($response->getBody());
     $request->setResponseSize(strlen($response->getBody()));
     return $request;
 }
开发者ID:rysk92,项目名称:opOpenSocialPlugin,代码行数:57,代码来源:opShindigRemoteContentFetcher.class.php

示例14: saveMetaDataForDocument

 public function saveMetaDataForDocument($id, $data)
 {
     $config = Zend_Registry::getInstance()->config->watson;
     $this->_httpClient->setUri($config->saveMetaDataUrl . $id);
     $this->_httpClient->setHeaders(array('X-SyncTimeout' => $config->timeout, 'Content-Type' => 'application/json', 'Accept' => 'application/json'));
     $response = $this->_httpClient->setRawData($data)->request(Zend_Http_Client::PUT);
     $responseBody = Zend_Json::decode($response->getBody());
     return $responseBody;
 }
开发者ID:beesheer,项目名称:freehdfootage,代码行数:9,代码来源:Client.php

示例15: set

 public function set($graph, $turtle)
 {
     $client = new Zend_Http_Client();
     $client->setUri($this->_endpoint . $graph);
     $client->setHeaders('Content-Type', 'application/x-turtle');
     $client->setRawData(FourStore_Namespace::to_turtle() . $turtle);
     $response = $client->request('PUT');
     return $response;
 }
开发者ID:klaffenboeck,项目名称:contextus,代码行数:9,代码来源:Store.php


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