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


PHP Zend_Http_Client::getLastRequest方法代码示例

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


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

示例1: validate

 public function validate($username, $password)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Options: ' . print_r($this->_options, true));
     }
     $url = isset($this->_options['url']) ? $this->_options['url'] : 'https://localhost/validate/check';
     $adapter = new Zend_Http_Client_Adapter_Socket();
     $adapter->setStreamContext($this->_options = array('ssl' => array('verify_peer' => isset($this->_options['ignorePeerName']) ? false : true, 'allow_self_signed' => isset($this->_options['allowSelfSigned']) ? true : false)));
     $client = new Zend_Http_Client($url, array('maxredirects' => 0, 'timeout' => 30));
     $client->setAdapter($adapter);
     $params = array('user' => $username, 'pass' => $password);
     $client->setParameterPost($params);
     try {
         $response = $client->request(Zend_Http_Client::POST);
     } catch (Zend_Http_Client_Adapter_Exception $zhcae) {
         Tinebase_Exception::log($zhcae);
         return Tinebase_Auth::FAILURE;
     }
     $body = $response->getBody();
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Request: ' . $client->getLastRequest());
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Response: ' . $body);
     }
     if ($response->getStatus() !== 200) {
         return Tinebase_Auth::FAILURE;
     }
     $result = Tinebase_Helper::jsonDecode($body);
     if (isset($result['result']) && $result['result']['status'] === true && $result['result']['value'] === true) {
         return Tinebase_Auth::SUCCESS;
     } else {
         return Tinebase_Auth::FAILURE;
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:35,代码来源:PrivacyIdea.php

示例2: testDoubleGetParameter

 /**
  * Test that setting the same parameter twice in the query string does not
  * get reduced to a single value only.
  *
  */
 public function testDoubleGetParameter()
 {
     $qstr = 'foo=bar&foo=baz';
     $this->client->setUri($this->baseuri . 'testGetData.php?' . $qstr);
     $res = $this->client->request('GET');
     $this->assertContains($qstr, $this->client->getLastRequest(), 'Request is expected to contain the entire query string');
 }
开发者ID:lortnus,项目名称:zf1,代码行数:12,代码来源:SocketTest.php

示例3: translate

 public function translate($message, $from, $to)
 {
     $url = "http://ajax.googleapis.com/ajax/services/language/translate";
     $client = new Zend_Http_Client($url, array('maxredirects' => 0, 'timeout' => 30));
     $langpair = $from . '|' . $to;
     $params = array('v' => '1.1', 'q' => $message, 'langpair' => $langpair, 'key' => 'ABQIAAAAMtXAc56OizxVFR_fG__ZZRSrxD5q6_ZpfA55q8xveFjTjZJnShSvPHZq2PGkhSBZ0_OObHUNyy0smw');
     /**
      * Zend_Http_Client
      */
     $client->setParameterPost($params);
     $client->setHeaders('Referer', 'http://sb6.ru');
     $response = $client->request("POST");
     //print_r ($response);
     $data = $response->getBody();
     $serverResult = json_decode($data);
     $status = $serverResult->responseStatus;
     // should be 200
     $result = '';
     if ($status == 200) {
         $result = $serverResult->responseData->translatedText;
     } else {
         echo "retry\n";
         print_r($client->getLastRequest());
         print_r($client->getLastResponse());
         die;
         return $this->translate($message, $from, $to);
     }
     return $result;
 }
开发者ID:sb15,项目名称:zend-ex-legacy,代码行数:29,代码来源:Translate.php

示例4: testGetLastRequest

 /**
  * Test we can get the last request as string
  *
  */
 public function testGetLastRequest()
 {
     $this->client->setUri($this->baseuri . 'testHeaders.php');
     $this->client->setParameterGet('someinput', 'somevalue');
     $this->client->setHeaders(array('X-Powered-By' => 'My Glorious Golden Ass'));
     $res = $this->client->request(Zend_Http_Client::TRACE);
     $this->assertEquals($this->client->getLastRequest(), $res->getBody(), 'Response body should be exactly like the last request');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:SocketTest.php

示例5: testGetLastRequest

 /**
  * Test we can get the last request as string
  *
  */
 public function testGetLastRequest()
 {
     $this->client->setUri($this->baseuri . 'testHeaders.php');
     $this->client->setParameterGet('someinput', 'somevalue');
     $this->client->setHeaders(array('X-Powered-By' => 'My Glorious Golden Ass'));
     $res = $this->client->request(HTTPClient::TRACE);
     if ($res->getStatus() == 405 || $res->getStatus() == 501) {
         $this->markTestSkipped("Server does not allow the TRACE method");
     }
     $this->assertEquals($this->client->getLastRequest(), $res->getBody(), 'Response body should be exactly like the last request');
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:15,代码来源:CommonHttpTests.php

示例6: testPutRequestsHonorSpecifiedContentType

 /**
  * @group ZF-10645
  */
 public function testPutRequestsHonorSpecifiedContentType()
 {
     $this->client->setUri($this->baseuri . 'ZF10645-PutContentType.php');
     $this->client->setMethod(Zend_Http_Client::PUT);
     $data = array('foo' => 'bar');
     $this->client->setRawData(http_build_query($data), 'text/html; charset=ISO-8859-1');
     $response = $this->client->request();
     $request = $this->client->getLastRequest();
     $this->assertContains('text/html; charset=ISO-8859-1', $request, $request);
     $this->assertContains('REQUEST_METHOD: PUT', $response->getBody(), $response->getBody());
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:14,代码来源:CommonHttpTests.php

示例7: testMultibyteRawPostDataZF2098

 /**
  * Test that we properly calculate the content-length of multibyte-encoded
  * request body
  *
  * This may file in case that mbstring overloads the substr and strlen
  * functions, and the mbstring internal encoding is a multibyte encoding.
  *
  * @link http://framework.zend.com/issues/browse/ZF-2098
  */
 public function testMultibyteRawPostDataZF2098()
 {
     $this->_client->setAdapter('Zend_Http_Client_Adapter_Test');
     $this->_client->setUri('http://example.com');
     $bodyFile = dirname(__FILE__) . '/_files/ZF2098-multibytepostdata.txt';
     $this->_client->setRawData(file_get_contents($bodyFile), 'text/plain');
     $this->_client->request('POST');
     $request = $this->_client->getLastRequest();
     if (!preg_match('/^content-length:\\s+(\\d+)/mi', $request, $match)) {
         $this->fail("Unable to find content-length header in request");
     }
     $this->assertEquals(filesize($bodyFile), (int) $match[1]);
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:22,代码来源:StaticTest.php

示例8: testMultiplePuts

 /**
  * @group ZF-11418
  */
 public function testMultiplePuts()
 {
     $this->client->setUri($this->baseuri . 'ZF10645-PutContentType.php');
     $data = 'test';
     $this->client->setRawData($data, 'text/plain');
     $this->client->setMethod(Zend_Http_Client::PUT);
     $response = $this->client->request();
     $this->assertContains('REQUEST_METHOD: PUT', $response->getBody(), $response->getBody());
     $this->client->resetParameters(true);
     $this->client->setUri($this->baseuri . 'ZF10645-PutContentType.php');
     $this->client->setMethod(Zend_Http_Client::PUT);
     $response = $this->client->request();
     $request = $this->client->getLastRequest();
     $this->assertNotContains('Content-Type: text/plain', $request);
 }
开发者ID:JeancarloPerez,项目名称:booking-system,代码行数:18,代码来源:CommonHttpTests.php

示例9: _mapResponseToModels

 /**
  * @throws OpenSocial_Rest_Exception
  * @param  $serviceType
  * @param Zend_Http_Response $response
  * @return array
  */
 protected function _mapResponseToModels($serviceType, Zend_Http_Response $response)
 {
     if (strpos($response->getHeader('Content-Type'), 'application/json') !== 0) {
         throw new OpenSocial_Rest_Exception("Unknown Content-Type for response:<br /> " . var_export($response, true) . ' with body: ' . var_export($response->getBody(), true) . ' for request: ' . $this->_httpClient->getLastRequest());
     }
     $modelClass = 'OpenSocial_Model_' . $this->_getModelTypeForService($serviceType);
     if (!class_exists($modelClass, true)) {
         throw new OpenSocial_Rest_Exception("Model class {$modelClass} not found for service {$serviceType}!");
     }
     /**
      * @var OpenSocial_Rest_Mapper_Interface $mapper
      */
     $mapper = new OpenSocial_Rest_Mapper_Json($modelClass);
     return $mapper->map($response->getBody());
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:21,代码来源:Client.php

示例10: getStreamData

 /**
  * Get Stream Data.
  *
  *
  * $data can also be stream (such as file) to which the data will be save.
  * 
  * $client->setStream(); // will use temp file
  * $response = $client->request('GET');
  * // copy file
  * copy($response->getStreamName(), "my/downloads/file");
  * // use stream
  * $fp = fopen("my/downloads/file2", "w");
  * stream_copy_to_stream($response->getStream(), $fp);
  * // Also can write to known file
  * $client->setStream("my/downloads/myfile")->request('GET');
  * 
  * @param resource $data
  * @param string $enctype
  * @return Default_Plugin_HttpBox
  */
 function getStreamData($filename = null)
 {
     if (is_string($filename)) {
         $this->client->setStream($filename)->request('GET');
     } else {
         $this->client->setStream();
         // will use temp file
         $this->client->request('GET');
     }
     // Запомним последний запрос в виде строки
     $this->last_request = $this->client->getLastRequest();
     // Запомним последний запрос в виде Zend_Http_Response
     $this->last_response = $this->client->getLastResponse();
     return $this;
 }
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:35,代码来源:HttpBox.php

示例11: testMultibyteRawPostDataZF2098

 /**
  * Test that we properly calculate the content-length of multibyte-encoded
  * request body
  *
  * This may file in case that mbstring overloads the substr and strlen
  * functions, and the mbstring internal encoding is a multibyte encoding.
  *
  * @link http://framework.zend.com/issues/browse/ZF-2098
  */
 public function testMultibyteRawPostDataZF2098()
 {
     $this->_client->setAdapter('Zend\\Http\\Client\\Adapter\\Test');
     $this->_client->setUri('http://example.com');
     $bodyFile = __DIR__ . '/_files/ZF2098-multibytepostdata.txt';
     $this->_client->setRawBody(file_get_contents($bodyFile));
     $this->_client->setEncType('text/plain');
     $this->_client->setMethod('POST');
     $this->_client->send();
     $request = $this->_client->getLastRequest();
     if (!preg_match('/^content-length:\\s+(\\d+)/mi', $request, $match)) {
         $this->fail("Unable to find content-length header in request");
     }
     $this->assertEquals(filesize($bodyFile), (int) $match[1]);
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:24,代码来源:StaticTest.php

示例12: provisionUser

 /**
  * 
  *
  * @param  $userId
  * @param  $attributes
  * @param  $spMetadata
  * @param  $idpMetadata
  * @return void
  */
 public function provisionUser($userId, $attributes, $spMetadata, $idpMetadata)
 {
     if (!$spMetadata['MustProvisionExternally']) {
         return;
     }
     // https://os.XXX.surfconext.nl/provisioning-manager/provisioning/jit.shtml?
     // provisionDomain=apps.surfnet.nl&provisionAdmin=admin%40apps.surfnet.nl&
     // provisionPassword=xxxxx&provisionType=GOOGLE&provisionGroups=true
     $client = new Zend_Http_Client($this->_url);
     $client->setHeaders(Zend_Http_Client::CONTENT_TYPE, 'application/json; charset=utf-8')->setParameterGet('provisionType', $spMetadata['ExternalProvisionType'])->setParameterGet('provisionDomain', $spMetadata['ExternalProvisionDomain'])->setParameterGet('provisionAdmin', $spMetadata['ExternalProvisionAdmin'])->setParameterGet('provisionPassword', $spMetadata['ExternalProvisionPassword'])->setParameterGet('provisionGroups', $spMetadata['ExternalProvisionGroups'])->setRawData(json_encode($this->_getData($userId, $attributes)))->request('POST');
     $additionalInfo = new EngineBlock_Log_Message_AdditionalInfo($userId, $idpMetadata['EntityId'], $spMetadata['EntityId'], null);
     EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: Sent HTTP request to provision user using " . __CLASS__, $additionalInfo);
     EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: URI: " . $client->getUri(true), $additionalInfo);
     EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: REQUEST: " . $client->getLastRequest(), $additionalInfo);
     EngineBlock_ApplicationSingleton::getLog()->debug("PROVISIONING: RESPONSE: " . $client->getLastResponse(), $additionalInfo);
 }
开发者ID:newlongwhitecloudy,项目名称:OpenConext-engineblock,代码行数:25,代码来源:ProvisioningManager.php

示例13: get

 /**
  * Return a single record
  *
  * @param string $_id
  * @param $_getDeleted get deleted records
  * @return Tinebase_Record_Interface
  */
 public function get($_id, $_getDeleted = FALSE)
 {
     // get basics
     $this->_httpClient->resetParameters();
     $this->_httpClient->setUri($this->_config->rest->url . "/REST/1.0/ticket/" . $_id . "/show");
     $this->_httpClient->setMethod(Zend_Http_Client::GET);
     $response = $this->_httpClient->request();
     $ticket = $this->_rawDataToTicket($response->getBody());
     // get history
     $this->_httpClient->resetParameters();
     $this->_httpClient->setUri($this->_config->rest->url . "/REST/1.0/ticket/" . $_id . "/history");
     $this->_httpClient->setParameterGet('format', 'l');
     $this->_httpClient->setMethod(Zend_Http_Client::GET);
     $response = $this->_httpClient->request();
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__FILE__ . '::' . __LINE__ . ' request :' . $this->_httpClient->getLastRequest());
     }
     //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__FILE__ . '::' . __LINE__ . ' response :' . $response->asString());
     $ticket->History = $this->_rawDataToHistory($response->getBody());
     return $ticket;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:28,代码来源:Rest.php

示例14: addSuperTag

 /**
  * Add Super Tag
  * 
  * NOTE: Super Tags cannot be created via the API, so they need to be created via the HTML interface before you apply them 
  *
  * @param Kohana_Company $company
  * @param string $tag
  */
 public function addSuperTag(Kohana_Company $company, Kohana_SuperTag $tag)
 {
     $realTagName = str_replace(' ', '_', strtolower($tag->getName()));
     $reqUrl = 'https://' . $this->_account . '.batchbook.com/service/companies/' . $company->getId() . '/super_tags/' . $realTagName . '.xml';
     error_log('requrl:' . $reqUrl);
     $httpClient = new Zend_Http_Client($reqUrl);
     $paramsPut = array();
     $fields = $tag->getFields();
     foreach ($fields as $key => $value) {
         //keys must be lower case and have spaces replaced with underscore
         $realKey = str_replace(' ', '_', strtolower($key));
         $realValue = urlencode($value);
         error_log('realKey:' . $realKey);
         error_log('realValue:' . $realValue);
         $paramsPut['super_tag[' . strtolower($realKey) . ']'] = $value;
     }
     $httpClient->setAuth($this->_token, 'x');
     $httpClient->setHeaders(Zend_Http_Client::CONTENT_TYPE, Zend_Http_Client::ENC_URLENCODED);
     $httpClient->setRawData(http_build_query($paramsPut, '', '&'), Zend_Http_Client::ENC_URLENCODED);
     $response = $httpClient->request(Zend_Http_Client::PUT);
     if (200 != $response->getStatus()) {
         //TODO: throw more specific exception
         throw new Exception('SuperTag \'' . $tag->getName() . '\' not added to Company with id=' . $company->getId() . "\n" . $response->getMessage() . "\n" . $response->getBody() . "\n" . $httpClient->getLastRequest());
     }
 }
开发者ID:robriggen,项目名称:kohana-batchbook,代码行数:33,代码来源:companyservice.php

示例15: _debugRequest

 /**
  * Debug helper function to log the last request/response pair against the DMS server
  *
  * @parma Zend_Http_Client $client Zend Http client object
  * @return void
  */
 private function _debugRequest(Zend_Http_Client $client)
 {
     $config = Zend_Registry::get('params');
     $logfile = '';
     // Capture DMS service parameters
     if (isset($config->dms) && isset($config->dms->logfile)) {
         $logfile = $config->dms->logfile;
     }
     if ($logfile != null && APPLICATION_ENV != 'production') {
         $request = $client->getLastRequest();
         $response = $client->getLastResponse();
         $fh = fopen($logfile, 'a+');
         fwrite($fh, $request);
         fwrite($fh, "\n\n");
         fwrite($fh, $response);
         fwrite($fh, "\n\n\n\n");
         fclose($fh);
     }
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:25,代码来源:DocumentUploader.php


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