本文整理汇总了PHP中Zend_Http_Client::setAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Http_Client::setAdapter方法的具体用法?PHP Zend_Http_Client::setAdapter怎么用?PHP Zend_Http_Client::setAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Http_Client
的用法示例。
在下文中一共展示了Zend_Http_Client::setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* @return $this
* @throws Zend_Http_Client_Exception
*/
public function init()
{
$this->initConfig();
$this->_http = new Zend_Http_Client();
$this->_http->setAdapter(new Zend_Http_Client_Adapter_Curl());
$this->_http->setHeaders(array('Accept' => 'application/' . static::API_RESPONSE_FORMAT, 'Authorization' => 'WSSE profile="UsernameToken"', 'X-WSSE' => $this->_getWsseHeader()));
return $this;
}
示例2: setXmlProvider
/**
* Sets the XML provider to be used in conjunction with SimpleXMLElement
*
* @param Varien_Http_Adapter_Curl $provider
*
* @return Bronto_Common_Helper_Data
*/
public function setXmlProvider(Varien_Http_Adapter_Curl $provider)
{
if (is_null($this->_client)) {
$this->_client = new Zend_Http_Client();
}
$this->_xmlProvider = $provider;
$this->_client->setAdapter($provider);
return $this;
}
示例3: __construct
/**
* Initialization of the class
*/
private function __construct()
{
// create a new handler for http using zend_http_cient
$this->_handler = new Zend_Http_Client();
// create a new adapter using curl
$curlAdapter = new Zend_Http_Client_Adapter_Curl();
// set the adapter for http client (curl)
$this->_handler->setAdapter($curlAdapter);
// set the main reguest method to be used by default
$this->_requestMethod = Zend_Http_Client::GET;
}
示例4: 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;
}
}
示例5: getTransports
private function getTransports()
{
$browserSocket = new \Buzz\Browser();
$browserSocket->setClient(new \Buzz\Client\FileGetContents());
$zendFrameworkOneHttpClientSocket = new \Zend_Http_Client();
$zendFrameworkOneHttpClientSocket->setAdapter(new \Zend_Http_Client_Adapter_Socket());
$zendFrameworkOneHttpClientProxy = new \Zend_Http_Client();
$zendFrameworkOneHttpClientProxy->setAdapter(new \Zend_Http_Client_Adapter_Proxy());
$zendFrameworkTwoHttpClientSocket = new \Zend\Http\Client();
$zendFrameworkTwoHttpClientSocket->setAdapter(new \Zend\Http\Client\Adapter\Socket());
$zendFrameworkTwoHttpClientProxy = new \Zend\Http\Client();
$zendFrameworkTwoHttpClientProxy->setAdapter(new \Zend\Http\Client\Adapter\Proxy());
$artaxClient = new \Amp\Artax\Client();
$transports = array(new fXmlRpc\Transport\StreamSocketTransport(), new fXmlRpc\Transport\BuzzBrowserBridge($browserSocket), new fXmlRpc\Transport\ZendFrameworkOneHttpClientBridge($zendFrameworkOneHttpClientSocket), new fXmlRpc\Transport\ZendFrameworkOneHttpClientBridge($zendFrameworkOneHttpClientProxy), new fXmlRpc\Transport\ZendFrameworkTwoHttpClientBridge($zendFrameworkTwoHttpClientSocket), new fXmlRpc\Transport\ZendFrameworkTwoHttpClientBridge($zendFrameworkTwoHttpClientProxy), new fXmlRpc\Transport\ArtaxBrowserBridge($artaxClient));
if (extension_loaded('curl') && !in_array('php_curl', $this->disabledExtensions)) {
$browserCurl = new \Buzz\Browser();
$browserCurl->setClient(new \Buzz\Client\Curl());
$transports[] = new fXmlRpc\Transport\BuzzBrowserBridge($browserCurl);
$zendFrameworkOneHttpClientCurl = new \Zend_Http_Client();
$zendFrameworkOneHttpClientCurl->setAdapter(new \Zend_Http_Client_Adapter_Curl());
$transports[] = new fXmlRpc\Transport\ZendFrameworkOneHttpClientBridge($zendFrameworkOneHttpClientCurl);
$zendFrameworkTwoHttpClientCurl = new \Zend\Http\Client();
$zendFrameworkTwoHttpClientCurl->setAdapter(new \Zend\Http\Client\Adapter\Curl());
$transports[] = new fXmlRpc\Transport\ZendFrameworkTwoHttpClientBridge($zendFrameworkTwoHttpClientCurl);
$guzzle = new \Guzzle\Http\Client();
$transports[] = new fXmlRpc\Transport\GuzzleBridge($guzzle);
$transports[] = new fXmlRpc\Transport\CurlTransport();
}
return $transports;
}
示例6: 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;
}
示例7: getClient
/**
* @return Zend_Http_Client
*/
public function getClient()
{
if ($this->_httpClient === null) {
$this->_httpClient = new Zend_Http_Client();
$this->_httpClient->setAdapter($this->_getAdapter());
$this->_httpClient->setHeaders($this->_getHeaders());
}
return $this->_httpClient;
}
示例8: getHttpClient
/**
* @return Zend_Http_Client
*/
public function getHttpClient()
{
$username = 'demo';
$password = sha1('demo');
$adapter = new Zend_Http_Client_Adapter_Curl();
$adapter->setConfig(array('curloptions' => array(CURLOPT_HTTPAUTH => CURLAUTH_DIGEST, CURLOPT_USERPWD => "{$username}:{$password}")));
$client = new Zend_Http_Client();
$client->setAdapter($adapter);
return $client;
}
示例9: testRedirectWithTrailingSpaceInLocationHeaderZF11283
/**
* Test that we can handle trailing space in location header
*
* @group ZF-11283
* @link http://framework.zend.com/issues/browse/ZF-11283
*/
public function testRedirectWithTrailingSpaceInLocationHeaderZF11283()
{
$this->_client->setUri('http://example.com/');
$this->_client->setAdapter('Zend_Http_Client_Adapter_Test');
$adapter = $this->_client->getAdapter();
/* @var $adapter Zend_Http_Client_Adapter_Test */
$response = "HTTP/1.1 302 Redirect\r\n" . "Content-Type: text/html; charset=UTF-8\r\n" . "Location: /test\r\n" . "Server: Microsoft-IIS/7.0\r\n" . "Date: Tue, 19 Apr 2011 11:23:48 GMT\r\n\r\n" . "RESPONSE";
$adapter->setResponse($response);
$res = $this->_client->request('GET');
$lastUri = $this->_client->getUri();
$this->assertEquals("/test", $lastUri->getPath());
}
示例10: 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]);
}
示例11: setUp
public function setUp()
{
$this->_adapter = new Zend_Http_Client_Adapter_Test();
$this->_storage = new Zend_Feed_Pubsubhubbub_Storage_Filesystem();
$this->_skey = sha1('http://www.example.com/callback' . 'http://www.example.com/topic' . 'subscription');
$this->_tkey = sha1('http://www.example.com/callback' . 'http://www.example.com/topic' . 'challenge');
$client = new Zend_Http_Client();
$client->setAdapter($this->_adapter);
Zend_Feed_Pubsubhubbub::setHttpClient($client);
$this->_callback = new Zend_Feed_Pubsubhubbub_HubServer_Callback();
$this->_callback->setStorage($this->_storage);
$this->_originalServer = $_SERVER;
$_SERVER['REQUEST_METHOD'] = 'POST';
}
示例12: 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]);
}
示例13: dispatch
public function dispatch($route = '', $data = array())
{
if (!Mage::helper('recapture')->isEnabled()) {
return false;
}
if (empty($route)) {
return false;
}
$adapter = new Zend_Http_Client_Adapter_Curl();
$client = new Zend_Http_Client('http://www.recapture.io/beacon/' . $route, array('timeout' => 1));
$client->setParameterPost($data);
$client->setAdapter($adapter);
$client->setHeaders('Api-Key', Mage::helper('recapture')->getApiKey());
$response = $client->request('POST');
return $response;
}
示例14: loadData
/**
* Lauch data collecting
*
* @param bool $printQuery
* @param bool $logQuery
* @return Varien_Data_Collection_Filesystem
*/
public function loadData($printQuery = false, $logQuery = false)
{
if ($this->isLoaded()) {
return $this;
}
try {
$client = new Zend_Http_Client();
$adapter = new Zend_Http_Client_Adapter_Curl();
$client->setAdapter($adapter);
$client->setUri($this->_getFeedUri());
$client->setConfig(array('maxredirects' => 0, 'timeout' => 30));
$client->setParameterGet('domain', Mage::app()->getRequest()->getHttpHost());
$responseBody = $client->request()->getBody();
$modules = Mage::helper('core')->jsonDecode($responseBody);
if (!is_array($modules)) {
throw new Exception('Decoding failed');
}
} catch (Exception $e) {
// @todo remove this fix and add error message
$modules = array('TM_Core' => array('code' => 'TM_Core', 'version' => '1.1.1', 'changelog' => '', 'link' => '', 'download_link' => '', 'identity_key_link' => ''), 'TM_License' => array('code' => 'TM_License', 'version' => '1.2.0', 'changelog' => '', 'link' => '', 'download_link' => '', 'identity_key_link' => ''), 'TM_Argento' => array('code' => 'TM_Argento', 'version' => '1.2.0', 'changelog' => '', 'link' => '', 'download_link' => '', 'identity_key_link' => '', 'changelog' => "\n1.2.0\nNew Pure theme added\nCss styles optimization\nCss styles improvements for small tablet devices\nRemoved php warnings during Argento installation\nFixed upsell products decoration with first/last classes\nAjaxSearch\n * Security bugfix\nAskit\n * Grammar errors fixed\nEasyslider\n * Nivo slider updated to version 3.2\nEasybanner\n * Title field should not be required, when using html mode\nFacebookLikeButton\n * Fixed access to facebook like button config section when internet connection is not available\nHighlight\n * Added translation of the highlight page title\nSoldtogether\n * Fixed bug, when no product is available, but soldtogether block is called\n\n1.1.2\nArgento\n * Html markup and css improvements. YSlow - 86 PageSpeed - 93\n * Review url fixed on product page\n * Lightboxpro config options updated to look good on mobile screens\n * Related products styles and image size improvements for small screen devices\n * All small images styles improved for mobile devices\n * Improved form styles\n * Fixed product listing on advanced search results\n * Facebook Like Button added\n * Scroll to top button added\nSoldtogether updated\n * Table prefix added to query\n * Amazon styled template will show only simple products\n * Fixed price calculation for bundle, configurable and grouped products when using amazon template\n * Collection queries improvements\nEasyslide updated\n * jQuery will not be added if nivo slider is not used\n * Default slider options added when creating new slider\n * Enabled option removed. Please use status option for each slider instance.\n * Load jQuery option now affects on adding jQuery library only: nivo javascript will be added if nivo slider is used.\nEasycatalogimg updated\n * Optional retina support added\n * Image dimensions added to html markup\nEasybanner updated\n * Ability to set image size added\n * Optional retina support added\n * Ability to use banner url for html mode added. Use the {{tm_banner_url}} variable in banner content.\n * Backend banner management interface improvements\n * Image dimensions added to html markup, when resizer is used\n\n1.1.1\nFixed column count with cache enabled on advanced search results and highlight pages\n\n1.1.0\nAdd to cart button improvements\nHeader styles made more compact for mobile devices\nSitemap toolbar style fixed\nProduct page tabs made horizontal for wide screens\nCheckout page design improvements\nProduct labels added to the product page image\nProduct labels output fixed for mobile devices\nAll module depends updated to the latest versions\n\n1.0.0\nRelease\n"), 'TM_ArgentoArgento' => array('code' => 'TM_ArgentoArgento', 'version' => '1.1.2', 'changelog' => "\n1.1.2\nSee TM_Argento changelog\nImproved form styles\n\n1.1.1\nSee TM_Argento changelog\n\n1.1.0\nSee TM_Argento changelog\nFixed box shadow around the product on category listing\n\n1.0.0\nRelease\n", 'link' => 'http://argentotheme.com', 'download_link' => 'https://argentotheme.com/downloadable/customer/products/', 'identity_key_link' => 'https://argentotheme.com/license/customer/identity/'), 'TM_ArgentoPure' => array('code' => 'TM_ArgentoPure', 'version' => '1.0.0', 'changelog' => "\n1.0.0\nRelease\n", 'link' => 'http://argentotheme.com', 'download_link' => 'https://argentotheme.com/downloadable/customer/products/', 'identity_key_link' => 'https://argentotheme.com/license/customer/identity/'));
}
foreach ($modules as $moduleName => $values) {
$values['id'] = $values['code'];
$this->_collectedModules[$values['code']] = $values;
}
// calculate totals
$this->_totalRecords = count($this->_collectedModules);
$this->_setIsLoaded();
// paginate and add items
$from = ($this->getCurPage() - 1) * $this->getPageSize();
$to = $from + $this->getPageSize() - 1;
$isPaginated = $this->getPageSize() > 0;
$cnt = 0;
foreach ($this->_collectedModules as $row) {
$cnt++;
if ($isPaginated && ($cnt < $from || $cnt > $to)) {
continue;
}
$item = new $this->_itemObjectClass();
$this->addItem($item->addData($row));
if (!$item->hasId()) {
$item->setId($cnt);
}
}
return $this;
}
示例15: getConsumer
public function getConsumer($config = null)
{
if (!($consumer = $this->_getData('consumer'))) {
if ($config === null) {
$config = $this->_getConsumerConfig();
}
$httpClient = new Zend_Http_Client();
$httpClient->setAdapter($this->_getAdapter());
if ($this->getTimeOut() > 0) {
$httpClient->setConfig(array('timeout' => $this->getTimeOut()));
}
$consumer = new Zend_Oauth_Consumer($config);
$consumer->setHttpClient($httpClient);
$this->setData('consumer', $consumer);
}
return $consumer;
}