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


PHP Zend_Http_Client::setConfig方法代码示例

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


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

示例1: __construct

 /**
  * Initialises an instance of the RecensusApi class.
  * 
  * @param string  $merchantId      Identifying token given to merchants by Recensus
  * @param string  $merchantSecret  Secret shared between merchant and Recensus for hashing requests.
  * @param boolean $throwExceptions If true will throw exceptions rather than emit notices.
  * 
  * @return void
  */
 public function __construct($merchantId, $merchantSecret, $throwExceptions = false)
 {
     $this->merchantId = $merchantId;
     $this->merchantSecret = $merchantSecret;
     $this->throwExceptions = $throwExceptions;
     $this->httpClient = new Zend_Http_Client();
     $this->httpClient->setConfig(array("timeout" => 3));
 }
开发者ID:recensus,项目名称:php-sdk,代码行数:17,代码来源:Api.php

示例2: setUp

 public function setUp()
 {
     $this->_httpTestAdapter = new Zend_Http_Client_Adapter_Test();
     $this->_httpClient = new Zend_Http_Client();
     $this->_httpClient->setConfig(array('adapter' => $this->_httpTestAdapter));
     $this->_asService = new Zend_Service_Audioscrobbler();
     $this->_asService->setHttpClient($this->_httpClient);
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:8,代码来源:AudioscrobblerTestCase.php

示例3: getHttpClient

 /**
  * Get Http Client
  *
  * @return Zend_Http_Client
  */
 public function getHttpClient()
 {
     if (!$this->_httpClient) {
         $this->_httpClient = new Zend_Http_Client();
         $this->_httpClient->setConfig(array('strictredirects' => true));
     }
     return $this->_httpClient;
 }
开发者ID:tenstone,项目名称:wecenter,代码行数:13,代码来源:Mpns.php

示例4: setUp

 public function setUp()
 {
     $this->_httpTestAdapter = new Http\Client\Adapter\Test();
     $this->_httpClient = new Http\Client();
     $this->_httpClient->setConfig(array('adapter' => $this->_httpTestAdapter));
     $this->_asService = new Audioscrobbler\Audioscrobbler();
     $this->_asService->setHttpClient($this->_httpClient);
 }
开发者ID:alab1001101,项目名称:zf2,代码行数:8,代码来源:AudioscrobblerTestCase.php

示例5: __construct

 /**
  * Constructor
  *
  * @param  string $vkId  app id
  * @param  string $vkKey security key
  * @param  string $urlAuth auth uri
  * @param  mixed  $scope
  */
 public function __construct($vkId, $vkKey, $urlAuth, $scope)
 {
     // access rules
     $this->_scope = (array) $scope;
     // default config
     $this->_config = array('urlAccessToken' => 'https://oauth.vk.com/access_token', 'urlAuthorize' => 'https://oauth.vk.com/authorize', 'urlApi' => 'https://api.vk.com/method/%s', 'urlAuth' => $urlAuth, 'apiVersion' => '5.37', 'client_id' => $vkId, 'client_secret' => $vkKey);
     // http client
     $this->_httpClient = new \Zend_Http_Client();
     $this->_httpClient->setConfig(array('storeResponse' => true, 'strictRedirects' => true, 'timeout' => 10, 'userAgent' => 'ZF-Vkontakte-SDK'));
 }
开发者ID:noglance,项目名称:ZF-Vkontakte-SDK,代码行数:18,代码来源:Api.php

示例6: __construct

 /**
  * Enter description here...
  *
  * @param Zend_Service_PayPal_Data_AuthInfo $auth_info
  * @param Zend_Http_Client                  $httpClient
  */
 public function __construct(Zend_Service_PayPal_Data_AuthInfo $authInfo, $uri = self::SERVICE_URI, $httpClient = null)
 {
     $this->authInfo = $authInfo;
     if ($httpClient instanceof Zend_Http_Client) {
         $this->httpClient = $httpClient;
     } else {
         // Create and configure the default HTTP client
         $this->httpClient = new Zend_Http_Client();
         $this->httpClient->setConfig(array('adapter' => 'Zend_Http_Client_Adapter_Socket', 'maxredirects' => 0, 'timeout' => 60, 'ssltransport' => 'ssl'));
     }
     $this->httpClient->setUri($uri);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:PayPal.php

示例7: __construct

 /**
  * Initiaise an instance of the RecensusWidget class.
  * 
  * @param string  $merchantId      Identifying token given to merchants by Recensus
  * @param string  $merchantSecret  Secret shared between merchant and Recensus for hashing requests.
  * @param array   $productData     Array of product data used to render the widget
  * @param boolean $throwExceptions If true will throw exceptions rather than emit notices.
  * 
  * @return RecensusWidget
  */
 public function __construct($userId, $merchantId, $merchantSecret, $productData = null, $throwExceptions = false)
 {
     $this->throwExceptions = $throwExceptions;
     $this->userId = $userId;
     $this->merchantId = $merchantId;
     $this->merchantSecret = $merchantSecret;
     if (!is_null($productData)) {
         $this->validateProductData($productData);
         $this->productData = $productData;
     }
     $this->httpClient = new Zend_Http_Client();
     $this->httpClient->setConfig(array("timeout" => 3));
 }
开发者ID:recensus,项目名称:php-sdk,代码行数:23,代码来源:Widget.php

示例8: getData

 public static function getData($url, $accesstoken, $redirects = true)
 {
     $client = new \Zend_Http_Client();
     $client->setUri($url);
     $client->setParameterGet('access_token', $accesstoken);
     if ($redirects) {
         $response = $client->request('GET')->getBody();
     } else {
         $client->setConfig(array('maxredirects' => 0));
         $response = $client->request()->getHeader('Location');
         $client->setConfig(array('maxredirects' => 5));
     }
     return $response;
 }
开发者ID:hYOUstone,项目名称:tsg,代码行数:14,代码来源:Consumer.php

示例9: setOptions

 /**
  * Set options
  *
  * Overrides any existing values.
  * 
  * If the options array has an 'options' entry it is forwarded to the
  * Zend_Http_Client. See the Zend_Http_Clientdocs for the many config
  * options available.
  *
  * The $options param should be an array or an object that has a toArray
  * method, like Zend_Config
  *
  * @param array|object $options
  * @param boolean $overwrite
  * @return Solarium_Client_Adapter_ZendHttp Provides fluent interface
  */
 public function setOptions($options, $overwrite = false)
 {
     parent::setOptions($options, $overwrite);
     // forward options to zendHttp instance
     if (null !== $this->_zendHttp) {
         // forward timeout setting
         $adapterOptions = array('timeout' => $this->getTimeout());
         // forward adapter options if available
         if (isset($this->_options['options'])) {
             $adapterOptions = array_merge($adapterOptions, $this->_options['options']);
         }
         $this->_zendHttp->setConfig($adapterOptions);
     }
     return $this;
 }
开发者ID:CodeforHawaii,项目名称:statedecoded,代码行数:31,代码来源:ZendHttp.php

示例10: urlAction

 /**
  * Action - url
  * check on the availability of URL
  *
  *
  * Access to the action is possible in the following paths:
  * - /utility/url
  *
  * @return void
  */
 public function urlAction()
 {
     // Получим обьект запроса
     $request = $this->getRequest();
     $params = $request->getParams();
     $type_action = $params['type_action'];
     if ($this->_isAjaxRequest) {
         $jsons = array();
         try {
             if ($type_action == 'check_exist') {
                 $url = $params['url'];
                 $client = new Zend_Http_Client();
                 $client->setUri($url);
                 $client->setConfig(array('maxredirects' => 0, 'timeout' => 5));
                 //Zend_Http_Request::
                 $response = $client->request();
                 //'CONNECT'
                 if ($response->isSuccessful()) {
                     $jsons['result'] = TRUE;
                 } else {
                     $jsons['result'] = FALSE;
                 }
             }
             $this->sendJson($jsons);
         } catch (Exception $exc) {
             $jsons['result'] = FALSE;
             $this->sendJson($jsons);
             return;
         }
     }
 }
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:41,代码来源:UtilityController.php

示例11: sendPOST

 /**
  * Send a POST request to the specified URL with the specified payload.
  * @param string $url
  * @param string $data
  * @return string Remote data
  **/
 public function sendPOST($url, $data = array())
 {
     $data['_fake_status'] = '200';
     // Zend makes it easier than the others...
     $this->instance->setConfig(array('useragent' => sprintf(Imgur::$user_agent, Imgur::$key)));
     $this->instance->setMethod(Zend_Http_Client::POST);
     $this->instance->setUri($url);
     $this->instance->setParameterPost($data);
     try {
         /** @var Zend_Http_Response */
         $response = $this->instance->request();
         return $response->getBody();
     } catch (Exception $e) {
         throw new Imgur_Exception("Unknown Failure during HTTP Request", null, $e);
     }
 }
开发者ID:plehnet,项目名称:Imgur-API-for-PHP,代码行数:22,代码来源:ZendHttpClient.php

示例12: getInfo

 /**
  *
  * Private method that queries REST service and returns SimpleXML response set
  * @param string $service name of Audioscrobbler service file we're accessing
  * @param string $params parameters that we send to the service if needded
  * @return SimpleXML result set
  */
 private function getInfo($service, $params = NULL)
 {
     $service = (string) $service;
     $params = (string) $params;
     try {
         if ($params == "") {
             $this->_client->setUri("http://ws.audioscrobbler.com{$service}");
         } else {
             $this->_client->setUri("http://ws.audioscrobbler.com{$service}?{$params}");
         }
         if ($this->testing == TRUE) {
             $adapter = new Zend_Http_Client_Adapter_Test();
             $this->_client->setConfig(array('adapter' => $adapter));
             $adapter->setResponse($this->testing_response);
         }
         $request = $this->_client->request();
         $response = $request->getBody();
         if ($response == 'No such path') {
             throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri());
         } else {
             if ($response == 'No user exists with this name.') {
                 throw new Zend_Http_Client_Exception('No user exists with this name');
             } else {
                 if ($request->isError()) {
                     throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
                 } else {
                     return simplexml_load_string($response);
                 }
             }
         }
     } catch (Zend_Http_Client_Exception $e) {
         throw $e;
     }
 }
开发者ID:josephholsten,项目名称:swaplady,代码行数:41,代码来源:Audioscrobbler.php

示例13: postMedia

 /**
  * Add an media file to mobypicture.
  *
  * @param string $filepath
  * @param string $title
  * @param string $description
  * @param string $format
  * @param array $options
  * @throws Zend_Http_Client_Exception if HTTP request fails or times out
  * @throws HausDesign_Service_Mobypicture_Exception If username is not set
  * @throws HausDesign_Service_Mobypicture_Exception If file can't read.
  * @throws HausDesign_Service_Mobypicture_Exception If file is larger then 16M.
  * @return mixed
  */
 public function postMedia($filepath, $title, $description = '', $format = self::FORMAT_XML, $options = array())
 {
     if (null == $this->_username || null == $this->_password) {
         throw new HausDesign_Service_Mobypicture_Exception('Username and password must be set.');
     }
     if (!is_readable($filepath)) {
         throw new HausDesign_Service_Mobypicture_Exception('File can\'t be read.');
     }
     if (filesize($filepath) > 16777216) {
         throw new HausDesign_Service_Mobypicture_Exception('File can\'t be larger then 16M.');
     }
     if (strlen($title) > self::MAX_LENGTH_TITLE) {
         $title = substr($title, 0, self::MAX_LENGTH_TITLE);
     }
     if (strlen($description) > self::MAX_LENGTH_DESCRIPTION) {
         $title = substr($title, 0, self::MAX_LENGTH_DESCRIPTION);
     }
     $options['t'] = $title;
     if ($description) {
         $options['d'] = $description;
     }
     $this->_localHttpClient->resetParameters();
     $this->_localHttpClient->setUri(self::MOBYPICTURE_API);
     $this->_localHttpClient->setParameterPost('action', 'postMediaUrl');
     $this->_localHttpClient->setFileUpload($filepath, 'i');
     $this->_localHttpClient->setParameterPost('u', $this->_username);
     $this->_localHttpClient->setParameterPost('p', $this->_password);
     $this->_localHttpClient->setParameterPost('k', $this->_apiKey);
     $this->_localHttpClient->setParameterPost('format', $format);
     $this->_localHttpClient->setConfig(array('timeout' => 30));
     foreach ($options as $option => $value) {
         $this->_localHttpClient->setParameterPost($option, $value);
     }
     return $this->_parseContent($this->_localHttpClient->request('GET')->getBody(), $format);
 }
开发者ID:hausdesign,项目名称:zf-library,代码行数:49,代码来源:Mobypicture.php

示例14: __callStatic

 /**
 * 
 * Меджик метод для вызова удаленных процедур
 * @param string $methodName
 * @param array $params
 * @return array
 * @author NuR
 * @throws Zend_Http_Client_Exception
 * @example
 * 
 *      $data = array(
 *      			  'Service' => 'Citizen',
                      'Method' => 'showOrderList',
                      'userid' => 1
                      );
    
    Evil_Json_Rpc::make($data);
 */
 public static function __callStatic($methodName, $params)
 {
     $client = self::$_client;
     if (null == $client) {
         /**
          * дефолтный адрес
          */
         if (null == self::$rpcUrl) {
             $config = Zend_Registry::get('config');
             self::$rpcUrl = isset($config['jsonrpc']['url']) ? $config['jsonrpc']['url'] : null;
         }
         $options = array('maxredirects' => 5, 'timeout' => 300, 'useragent' => 'Evil_Json_Rpc');
         $client = new Zend_Http_Client(self::$rpcUrl);
         $client->setConfig($options);
         self::$_client = $client;
     }
     $requestParams = array('method' => $methodName, 'params' => $params, 'id' => self::$_requestId++);
     $request = Zend_Json::encode($requestParams);
     $client->setHeaders('Content-type', 'application/json');
     $client->setRawData($request);
     $response = $client->request('POST');
     try {
         return Zend_Json::decode($response->getBody());
     } catch (Exception $e) {
         return array('ex' => $e->__toString(), 'response' => $response->getBody());
     }
 }
开发者ID:nurikk,项目名称:EvilRocketFramework,代码行数:45,代码来源:Rpc.php

示例15: request

 /**
  * Perform an API request to Amazon
  *
  * @param string $path
  *    REST path e.g. user/profile
  * @param array $postParams
  *    POST paramaters
  * @return result
  */
 public function request($path, array $postParams = array())
 {
     $sandbox = Mage::getStoreConfig('payment/amazon_payments/sandbox') ? 'sandbox.' : '';
     $client = new Zend_Http_Client();
     $client->setUri("https://api.{$sandbox}amazon.com/{$path}");
     $client->setConfig($this->http_client_config);
     $client->setMethod($postParams ? 'POST' : 'GET');
     foreach ($postParams as $key => $value) {
         $client->setParameterPost($key, $value);
     }
     try {
         $response = $client->request();
     } catch (Zend_Http_Client_Adapter_Exception $e) {
         Mage::logException($e);
         return;
     }
     $data = $response->getBody();
     try {
         $data = Zend_Json::decode($data, true);
     } catch (Exception $e) {
         Mage::logException($e);
     }
     if (empty($data)) {
         return false;
     } else {
         return $data;
     }
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:37,代码来源:Api.php


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