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


PHP Zend_Http_Client::resetParameters方法代码示例

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


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

示例1: prepare

 /**
  * HTTP client preparation procedures - should be called before every API 
  * call. 
  * 
  * Will clean up the HTTP client parameters, set the request method to POST
  * and add the always-required authentication information
  * 
  * @param  string $method The API method we are about to use
  * @return void
  */
 protected function prepare($method)
 {
     // Reset parameters
     $this->httpClient->resetParameters();
     // Add authentication data
     $this->httpClient->setMethod('POST');
     $this->httpClient->setParameterPost(array('USER' => $this->authInfo->getUser(), 'PWD' => $this->authInfo->getPassword(), 'SIGNATURE' => $this->authInfo->getSignature(), 'VERSION' => '2.3', 'METHOD' => $method));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:18,代码来源:PayPal.php

示例2: _getClient

 /**
  * @return Zend_Http_Client
  */
 protected function _getClient()
 {
     if (is_null($this->_httpClient)) {
         if (!$this->_apiUri) {
             Mage::throwException('Please specify API uri.');
         }
         $this->_httpClient = new Zend_Http_Client($this->_apiUri);
     }
     return $this->_httpClient->resetParameters(true);
 }
开发者ID:xiaoguizhidao,项目名称:ortodon,代码行数:13,代码来源:Ru.php

示例3: getHttpClient

 /**
  * Return the singleton instance of the HTTP Client. Note that
  * the instance is reset and cleared of previous parameters and
  * Authorization header values.
  *
  * @return Zend_Http_Client
  */
 public static function getHttpClient()
 {
     if (!isset(self::$httpClient)) {
         self::$httpClient = new Zend_Http_Client();
     } else {
         self::$httpClient->setHeaders('Authorization', null);
         self::$httpClient->resetParameters();
     }
     return self::$httpClient;
 }
开发者ID:brianbui171,项目名称:website_zend_1.11,代码行数:17,代码来源:Oauth.php

示例4: doSendInternalRequest

 /**
  * {@inheritdoc}
  */
 protected function doSendInternalRequest(InternalRequestInterface $internalRequest)
 {
     $this->client->resetParameters(true)->setConfig(array('httpversion' => $internalRequest->getProtocolVersion(), 'timeout' => $this->getConfiguration()->getTimeout(), 'maxredirects' => 0))->setUri($url = (string) $internalRequest->getUrl())->setMethod($internalRequest->getMethod())->setHeaders($this->prepareHeaders($internalRequest))->setRawData($this->prepareBody($internalRequest));
     try {
         $response = $this->client->request();
     } catch (\Exception $e) {
         throw HttpAdapterException::cannotFetchUrl($url, $this->getName(), $e->getMessage());
     }
     return $this->getConfiguration()->getMessageFactory()->createResponse($response->getStatus(), $response->getMessage(), $response->getVersion(), $response->getHeaders(), BodyNormalizer::normalize(function () use($response) {
         return $response instanceof \Zend_Http_Response_Stream ? $response->getStream() : $response->getBody();
     }, $internalRequest->getMethod()));
 }
开发者ID:lamenath,项目名称:fbp,代码行数:15,代码来源:Zend1HttpAdapter.php

示例5: request

 /**
  * Execute CheddarGetter API request
  *
  * @param string $url Url to the API action
  * @param string $username Username
  * @param string $password Password
  * @param array|null $args HTTP post key value pairs
  * @return string Body of the response from the CheddarGetter API
  * @throws Zend_Http_Client_Exception A Zend_Http_Client_Exception may
  * be thrown under a number of conditions but most likely if the tcp socket
  * fails to connect.
  */
 public function request($url, $username, $password, array $args = null)
 {
     // reset
     $this->_client->setUri($url);
     $this->_client->resetParameters();
     $this->_client->setMethod(Zend_Http_Client::GET);
     $this->_client->setAuth($username, $password);
     if ($args) {
         $this->_client->setMethod(Zend_Http_Client::POST);
         $this->_client->setParameterPost($args);
     }
     $response = $this->_client->request();
     return $response->getBody();
 }
开发者ID:robinsonryan,项目名称:cheddar-getter,代码行数:26,代码来源:ZendAdapter.php

示例6: postComment

 /**
  * Post a comment.
  *
  * @param string $code
  * @param string $message
  * @param array $options
  * @param string $format
  */
 public function postComment($code, $message, $options = array(), $format = self::FORMAT_XML)
 {
     $defaults = array('name' => '', 'email' => '', 'tweet' => 0);
     $options = array_merge($defaults, $options);
     if (!strlen($options['name']) && !strlen($options['email'])) {
         if (null == $this->_username && null == $this->_password) {
             throw new HausDesign_Service_Mobypicture_Exception('name and email or username and password should by defined');
         }
     }
     $this->_localHttpClient->resetParameters();
     $this->_localHttpClient->setUri(self::MOBYPICTURE_API);
     $this->_localHttpClient->setParameterGet('action', 'postComment');
     if (!strlen($options['name']) && !strlen($options['email'])) {
         $this->_localHttpClient->setParameterGet('u', $this->_username);
         $this->_localHttpClient->setParameterGet('p', $this->_password);
     }
     $this->_localHttpClient->setParameterGet('k', $this->_apiKey);
     $this->_localHttpClient->setParameterGet('tinyurl_code ', $code);
     $this->_localHttpClient->setParameterGet('message', $code);
     $this->_localHttpClient->setParameterGet('format', $format);
     foreach ($options as $option => $value) {
         $this->_localHttpClient->setParameterGet($option, $value);
     }
     return $this->_parseContent($this->_localHttpClient->request('GET')->getBody(), $format);
 }
开发者ID:hausdesign,项目名称:zf-library,代码行数:33,代码来源:Mobypicture.php

示例7: getFeed

 /**
  * Retreive feed object
  *
  * @param string $uri
  * @return Zend_Feed
  */
 public function getFeed($uri)
 {
     $feed = new Zend_Feed();
     $this->_httpClient->resetParameters();
     $feed->setHttpClient($this->_httpClient);
     return $feed->import($uri);
 }
开发者ID:josephholsten,项目名称:swaplady,代码行数:13,代码来源:Gdata.php

示例8: testResetParameters

    /**
     * Make sure we can reset the parameters between consecutive requests
     *
     */
    public function testResetParameters()
    {
        $params = array(
            'quest' => 'To seek the holy grail',
            'YourMother' => 'Was a hamster',
            'specialChars' => '<>$+ &?=[]^%',
            'array' => array('firstItem', 'secondItem', '3rdItem')
        );

        $headers = array("X-Foo" => "bar");

        $this->client->setParameterPost($params);
        $this->client->setParameterGet($params);
        $this->client->setHeaders($headers);

        $res = $this->client->request('POST');

        $this->assertContains(serialize($params) . "\n" . serialize($params),
            $res->getBody(), "returned body does not contain all GET and POST parameters (it should!)");

        $this->client->resetParameters();
        $res = $this->client->request('POST');

        $this->assertNotContains(serialize($params), $res->getBody(),
            "returned body contains GET or POST parameters (it shouldn't!)");
        $this->assertContains($headers["X-Foo"], $this->client->getHeader("X-Foo"), "Header not preserved by reset");

        $this->client->resetParameters(true);
        $this->assertNull($this->client->getHeader("X-Foo"), "Header preserved by reset(true)");
    }
开发者ID:nbcutech,项目名称:o3drupal,代码行数:34,代码来源:CommonHttpTests.php

示例9: _request

 /**
  * Makes request and checks the result according uri
  *
  * @param  string $uri
  * @return stdClass
  * @throws \Exception when the result was unsuccessful
  * @throws \UnexpectedValueException JSON parsing error
  */
 protected function _request($uri)
 {
     // request object
     $request = $this->_httpClient->resetParameters(true)->setUri($uri);
     // let's send request and check what we have
     try {
         $response = $request->request();
     } catch (\Zend_Http_Client_Exception $e) {
         throw new \Exception('Client request was unsuccessful', $e->getCode(), $e);
     }
     if (!$response->isSuccessful()) {
         throw new \Exception("Request failed({$response->getStatus()}): {$response->getMessage()} at " . $request->getLastRequest());
     }
     // the response has JSON format, we should decode it
     try {
         $decoded = \Zend_Json::decode($response->getBody(), \Zend_Json::TYPE_OBJECT);
     } catch (\Zend_Json_Exception $e) {
         throw new \UnexpectedValueException('Response is not JSON: ' . $response->getBody());
     }
     // do we have something interesting?
     if (isset($decoded->error)) {
         if (!isset($decoded->error->error_code)) {
             $this->_errorMessage = $decoded->error;
         } else {
             throw new \Exception("Response contains error({$decoded->error->error_code}): " . $decoded->error->error_msg);
         }
     }
     return $decoded;
 }
开发者ID:noglance,项目名称:ZF-Vkontakte-SDK,代码行数:37,代码来源:Api.php

示例10: _httpRequest

 /**
  * Performs HTTP request to given $url using given HTTP $method.
  * Send additinal query specified by variable/value array,
  * On success returns HTTP response without headers, false on failure.
  *
  * @param string $url OpenID server url
  * @param string $method HTTP request method 'GET' or 'POST'
  * @param array $params additional qwery parameters to be passed with
  * @param int &$staus HTTP status code
  *  request
  * @return mixed
  */
 protected function _httpRequest($url, $method = 'GET', array $params = array(), &$status = null)
 {
     $client = $this->_httpClient;
     if ($client === null) {
         $client = new Zend_Http_Client($url, array('maxredirects' => 4, 'timeout' => 15, 'useragent' => 'Zend_OpenId'));
     } else {
         $client->setUri($url);
     }
     $client->resetParameters();
     if ($method == 'POST') {
         $client->setMethod(Zend_Http_Client::POST);
         $client->setParameterPost($params);
     } else {
         $client->setMethod(Zend_Http_Client::GET);
         $client->setParameterGet($params);
     }
     try {
         $response = $client->request();
     } catch (Exception $e) {
         $this->_setError('HTTP Request failed: ' . $e->getMessage());
         return false;
     }
     $status = $response->getStatus();
     $body = $response->getBody();
     if ($status == 200 || $status == 400 && !empty($body)) {
         return $body;
     } else {
         $this->_setError('Bad HTTP response');
         return false;
     }
 }
开发者ID:highfidelity,项目名称:love,代码行数:43,代码来源:Consumer.php

示例11: getHttpClient

 /**
  * Return the singleton instance of the HTTP Client. Note that
  * the instance is reset and cleared of previous parameters GET/POST.
  * Headers are NOT reset but handled by this component if applicable.
  *
  * @return Zend_Http_Client
  */
 public static function getHttpClient()
 {
     if (!isset(self::$httpClient)):
         self::$httpClient = new Zend_Http_Client;
     else:
         self::$httpClient->resetParameters();
     endif;
     return self::$httpClient;
 }
开发者ID:nhp,项目名称:shopware-4,代码行数:16,代码来源:Pubsubhubbub.php

示例12: resetParameters

 /**
  * Clear all GET and POST parameters
  *
  * Should be used to reset the request parameters if the client is
  * used for several concurrent requests.
  *
  * clearAll parameter controls if we clean just parameters or also
  * headers and last_*
  *
  * @param bool $clearAll Should all data be cleared?
  * @return Default_Plugin_HttpBox
  */
 function resetParameters($clearAll = false)
 {
     $this->last_url = null;
     $this->last_request = null;
     $this->last_response = null;
     $this->last_cookies = null;
     $this->last_config = null;
     $this->client->resetParameters($clearAll);
     return $this;
 }
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:22,代码来源:HttpBox.php

示例13: delete

 /**
  * DELETE entry with client object
  *
  * @param mixed $data The Zend_Gdata_App_Entry or URL to delete
  * @return void
  * @throws Zend_Gdata_App_Exception
  * @throws Zend_Gdata_App_HttpException
  * @throws Zend_Gdata_App_InvalidArgumentException
  */
 public function delete($data, $remainingRedirects = null)
 {
     require_once 'Zend/Http/Client/Exception.php';
     if ($remainingRedirects === null) {
         $remainingRedirects = self::getMaxRedirects();
     }
     if (is_string($data)) {
         $uri = $data;
     } elseif ($data instanceof Zend_Gdata_App_Entry) {
         $editLink = $data->getEditLink();
         if ($editLink != null) {
             $uri = $editLink->getHref();
         }
     } else {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('You must specify the data to post as either a string or a child of Zend_Gdata_App_Entry');
     }
     if ($uri === null) {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('You must specify an URI which needs deleted.');
     }
     $this->_httpClient->resetParameters();
     $this->_httpClient->setHeaders('x-http-method-override', null);
     $this->_httpClient->setUri($uri);
     $this->_httpClient->setConfig(array('maxredirects' => 0));
     try {
         if (Zend_Gdata_App::getHttpMethodOverride()) {
             $this->_httpClient->setHeaders(array('X-HTTP-Method-Override: DELETE'));
             $this->_httpClient->setRawData('');
             $response = $this->_httpClient->request('POST');
         } else {
             $response = $this->_httpClient->request('DELETE');
         }
     } catch (Zend_Http_Client_Exception $e) {
         require_once 'Zend/Gdata/App/HttpException.php';
         throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
     }
     if ($response->isRedirect()) {
         if ($remainingRedirects > 0) {
             $newUri = $response->getHeader('Location');
             $response = $this->delete($newUri, $remainingRedirects - 1);
         } else {
             require_once 'Zend/Gdata/App/HttpException.php';
             throw new Zend_Gdata_App_HttpException('No more redirects allowed', null, $response);
         }
     }
     if (!$response->isSuccessful()) {
         require_once 'Zend/Gdata/App/HttpException.php';
         $exception = new Zend_Gdata_App_HttpException('Expected response code 200, got ' . $response->getStatus());
         $exception->setResponse($response);
         throw $exception;
     }
     return $response;
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:63,代码来源:App.php

示例14: _getZendHttpClient

 /**
  * private getter for the Zend_Http_Client
  * if not set yet it will be instantiated
  *
  * @return Zend_Http_Client
  */
 protected function _getZendHttpClient()
 {
     if (is_null($this->_httpClient)) {
         // @todo implement SSL check here
         $this->_httpClient = new Zend_Http_Client($this->_getRequestUrl());
     } else {
         $this->_httpClient->resetParameters(true);
         $this->_httpClient->setUri($this->_getRequestUrl());
     }
     return $this->_httpClient;
 }
开发者ID:wirecard,项目名称:magento-wcs,代码行数:17,代码来源:ClientAbstract.php

示例15: login

 /**
  * Login to the API, set the auth header.
  * @throws Zend_Http_Client_Exception
  * @throws Exception
  */
 protected function login()
 {
     $this->client->setUri($this->config['uri'] . $this->config['endpoints']['auth']);
     $this->client->setParameterPost($this->config['credentials']);
     $response = $this->client->request('POST');
     if ($response->getStatus() > 299) {
         throw new Exception('Unable to login, user credentials in config incorrect');
     }
     $jsonResponse = json_decode($response->getBody(), true);
     $this->client->resetParameters();
     $this->client->setHeaders('Authorization', 'Bearer ' . $jsonResponse['access_token']);
 }
开发者ID:openeyes,项目名称:openeyes,代码行数:17,代码来源:OptomPortalConnection.php


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