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


PHP Zend_Rest_Client::getHttpClient方法代码示例

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


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

示例1: __construct

 /**
  * Constructor
  * @param Data $helper
  * @param \Koklu\Recommender\Logger\Event $eventLogger
  * @param \Koklu\Recommender\Logger\Recommender $recommenderLogger
  * @throws \Zend_Http_Client_Exception
  */
 public function __construct(Data $helper, \Koklu\Recommender\Logger\Event $eventLogger, \Koklu\Recommender\Logger\Recommender $recommenderLogger)
 {
     $this->_helper = $helper;
     $this->_eventLogger = $eventLogger;
     $this->_recommendLogger = $recommenderLogger;
     $this->_client = new \Koklu\Rest\Json\Client($helper->getApiBaseUrl());
     $this->_client->getHttpClient()->setConfig(['keepalive' => true, 'useragent' => 'Magento2 Recommender Client', 'maxredirects' => 0])->setUnmaskStatus(true);
 }
开发者ID:halk,项目名称:recowise-magento2-demo,代码行数:15,代码来源:Client.php

示例2: startClient

 /**
  * Starts the client by using the given rest server url
  *
  * @param $url
  */
 public function startClient($url)
 {
     $this->client = new Zend_Rest_Client($url);
     // Get instance of Zend_Http_Client
     $httpClient = $this->client->getHttpClient();
     // Change the timeout
     $httpClient->setConfig(array("timeout" => 7));
 }
开发者ID:ClaudioThomas,项目名称:shopware-4,代码行数:13,代码来源:Client.php

示例3: webSearch

    /**
     * Perform a web content search on search.yahoo.com.  A basic query
     * consists simply of a text query.  Additional options that can be
     * specified consist of:
     * 'results'    => int  How many results to return, max is 50
     * 'start'      => int  The start offset for search results
     * 'language'   => lang  The target document language to match
     * 'type'       => (all|any|phrase)  How the query should be parsed
     * 'site'       => string  A site to which your search should be restricted
     * 'format'     => (any|html|msword|pdf|ppt|rss|txt|xls)
     * 'adult_ok'   => bool  permit 'adult' content in the search results
     * 'similar_ok' => bool  permit similar results in the result set
     * 'country'    => string  The country code for the content searched
     * 'license'    => (any|cc_any|cc_commercial|cc_modifiable)  The license of content being searched
     * 'region'     => The regional search engine on which the service performs the search. default us.
     *
     * @param  string $query    the query being run
     * @param  array  $options  any optional parameters
     * @return Zend_Service_Yahoo_WebResultSet  The return set
     * @throws Zend\Service\Exception
     */
    public function webSearch($query, array $options = array())
    {
        static $defaultOptions = array('type'     => 'all',
                                       'start'    => 1,
                                       'results'  => 10,
                                       'format'   => 'any');

        $options = $this->_prepareOptions($query, $options, $defaultOptions);
        $this->_validateWebSearch($options);

        $this->_rest->getHttpClient()->resetParameters();
        $this->_rest->setUri('http://search.yahooapis.com');
        $response = $this->_rest->restGet('/WebSearchService/V1/webSearch', $options);

        if ($response->isError()) {
            throw new Zend\Service\Exception('An error occurred sending request. Status code: ' .
                                             $response->getStatus());
        }

        $dom = new DOMDocument();
        $dom->loadXML($response->getBody());

        self::_checkErrors($dom);

        return new Zend_Service_Yahoo_WebResultSet($dom);
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:47,代码来源:Yahoo.php

示例4: itemLookup

 /**
  * Look up item(s) by ASIN
  *
  * @param  string $asin    Amazon ASIN ID
  * @param  array  $options Query Options
  * @see http://www.amazon.com/gp/aws/sdk/main.html/102-9041115-9057709?s=AWSEcommerceService&v=2005-10-05&p=ApiReference/ItemLookupOperation
  * @throws Zend_Service_Exception
  * @return Zend_Service_Amazon_Item|Zend_Service_Amazon_ResultSet
  */
 public function itemLookup($asin, array $options = array())
 {
     $defaultOptions = array('IdType' => 'ASIN', 'ResponseGroup' => 'Small');
     $options['ItemId'] = (string) $asin;
     $options = $this->_prepareOptions('ItemLookup', $options, $defaultOptions);
     $this->_rest->getHttpClient()->resetParameters();
     $response = $this->_rest->restGet('/onca/xml', $options);
     if ($response->isError()) {
         /**
          * @see Zend_Service_Exception
          */
         require_once 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception('An error occurred sending request. Status code: ' . $response->getStatus());
     }
     $dom = new DOMDocument();
     $dom->loadXML($response->getBody());
     self::_checkErrors($dom);
     $xpath = new DOMXPath($dom);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
     $items = $xpath->query('//az:Items/az:Item');
     if ($items->length == 1) {
         /**
          * @see Zend_Service_Amazon_Item
          */
         require_once 'Zend/Service/Amazon/Item.php';
         return new Zend_Service_Amazon_Item($items->item(0));
     }
     /**
      * @see Zend_Service_Amazon_ResultSet
      */
     require_once 'Zend/Service/Amazon/ResultSet.php';
     return new Zend_Service_Amazon_ResultSet($dom);
 }
开发者ID:Mendim,项目名称:gtv-resources,代码行数:42,代码来源:Amazon.php

示例5: _setHeaders

 /**
  * Set special headers for request
  *
  * @param  string  $apiToken
  * @param  string  $apiVersion
  * @param  string  $requestSignature
  * @return void
  */
 protected function _setHeaders($apiToken, $apiVersion, $requestSignature = null)
 {
     $headers = array('User-Agent' => 'TicketEvolution_Webservice', 'X-Token' => (string) $apiToken, 'Accept' => (string) 'application/json');
     if (!empty($requestSignature)) {
         $headers['X-Signature'] = (string) $requestSignature;
     }
     $this->_rest->getHttpClient()->setHeaders($headers);
 }
开发者ID:4ticketdeals,项目名称:ticketevolution-php,代码行数:16,代码来源:Webservice.php

示例6: findPackstations

 /**
  * Call corresponding web service method and return the results.
  *
  * @deprecated Zend_Rest_Client does not format URI accordingly
  * @param array $params
  * @return array The parsed packstation data
  * @throws Dhl_Account_Exception
  */
 public function findPackstations(array $params)
 {
     /* @var $helper Dhl_Account_Helper_Data */
     $helper = Mage::helper('dhlaccount/data');
     $params = $this->getDefaultParams() + $params;
     try {
         $result = $this->getClient()->postfinder($params)->get();
     } catch (Zend_Rest_Client_Result_Exception $e) {
         $response = $this->client->getHttpClient()->getLastResponse();
         $helper->log($this->client->getHttpClient()->getLastRequest());
         $helper->log(sprintf("%s\nHTTP/%s %s %s", $e->getMessage(), $response->getVersion(), $response->getStatus(), $response->getMessage()));
         throw new Dhl_Account_Exception($helper->__('An error occured while retrieving the packstation data.'));
     }
     // TODO(nr): transform web service response to usable output.
     return $result;
 }
开发者ID:igorvasiliev4,项目名称:magento_code,代码行数:24,代码来源:Adapter.php

示例7: testRestPut

    public function testRestPut()
    {
        $expXml   = file_get_contents($this->path . 'returnString.xml');
        $response = "HTTP/1.0 200 OK\r\n"
                  . "X-powered-by: PHP/5.2.0\r\n"
                  . "Content-type: text/xml\r\n"
                  . "Content-length: " . strlen($expXml) . "\r\n"
                  . "Server: Apache/1.3.34 (Unix) PHP/5.2.0)\r\n"
                  . "Date: Tue, 06 Feb 2007 15:01:47 GMT\r\n"
                  . "Connection: close\r\n"
                  . "\r\n"
                  . $expXml;
        $this->adapter->setResponse($response);

        $reqXml   = file_get_contents($this->path . 'returnInt.xml');
        $response = $this->rest->restPut('/rest/', $reqXml);
        $this->assertTrue($response instanceof Zend_Http_Response);
        $body = $response->getBody();
        $this->assertContains($expXml, $response->getBody());

        $request = Zend_Rest_Client::getHttpClient()->getLastRequest();
        $this->assertContains($reqXml, $request, $request);
    }
开发者ID:nbcutech,项目名称:o3drupal,代码行数:23,代码来源:ClientTest.php

示例8: setUp

 protected function setUp()
 {
     $this->_finding = new Zend_Service_Ebay_Finding(constant('TESTS_ZEND_SERVICE_EBAY_ONLINE_APPID'));
     $this->_httpClientOriginal = Zend_Rest_Client::getHttpClient();
     Zend_Rest_Client::setHttpClient(new Zend_Http_Client());
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:6,代码来源:OnlineTest.php

示例9: _getClient

 protected function _getClient($baseUrl, $includeAccessToken = true)
 {
     $client = new Zend_Rest_Client($baseUrl);
     $headers = array('Accept' => 'application/json');
     if ($includeAccessToken) {
         $headers['Authorization'] = 'Bearer ' . $this->_getAccessToken();
     }
     $client->getHttpClient()->setHeaders($headers);
     return $client;
 }
开发者ID:jronatay,项目名称:ultimo-magento-jron,代码行数:10,代码来源:Authorization.php

示例10: testFindAllByMasterFilterAlias

 /**
  * @group EricssonListPagingInt
  */
 public function testFindAllByMasterFilterAlias()
 {
     Zend_Rest_Client::getHttpClient()->setConfig(array('timeout' => 60));
     $rawFilters = array('alias' => 'alias');
     $filterList = SimService::getInstance()->buildFilterList($rawFilters);
     $filters = array('organizationId' => Application\Model\Organization\OrgMasterModel::ORG_TYPE . '-' . 'master11111111111111111111111111', 'filterList' => $filterList);
     $sims = $this->simMapper->findAll($filters, array('count' => 100));
     $this->assertNotNull($sims);
     $this->assertGreaterThanOrEqual('1', $sims->getCount());
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:13,代码来源:SimMapperEricssonIntListTest.php

示例11: getActiveState

 /**
  * check whether the bar is active
  *
  * @return array
  */
 public function getActiveState()
 {
     $csConfig = Mage::getModel("commercesciences_base/config")->load("1");
     if (!$csConfig) {
         //we must be already at least on step 1, so the DB record has to exist
         Mage::log("Error - no csConfig");
         return array('error' => $this->__("Error ocurred. Your updates weren't saved. Please contact ComemrceScience for support (error id: 005)"));
     }
     Mage::log("csConfig=" . print_r($csConfig, true), true);
     // TODO Ron Gross 2/1/2013 - refactor into a method
     $RESTClient = new Zend_Rest_Client($csConfig->getCsApiUrl());
     $httpClient = $RESTClient->getHttpClient();
     $httpClient->setConfig(array("timeout" => 30));
     try {
         $response = $RESTClient->restGet("/magento/getBarStatus", array('userID' => $csConfig->getUserId(), 'securityToken' => $csConfig->getSecurityToken()));
         $responseJson = $response->getBody();
         $parsedResponseArr = $this->stdObject2Array(json_decode($responseJson));
         if (!isset($parsedResponseArr['good'])) {
             Mage::log("Server busy");
             return array('error' => $this->__("The CommerceSciences server is currently busy, your updates weren't saved. Please try again later.  (error id: 006)"));
         }
         if ($parsedResponseArr['good'] == false) {
             if (isset($parsedResponseArr['fieldErrors']) && $parsedResponseArr['fieldErrors']) {
                 $fieldErrorsArr = $this->stdObject2Array($parsedResponseArr['fieldErrors']);
                 $errorMsg = '';
                 foreach ($fieldErrorsArr as $field => $fError) {
                     $errorMsg .= "<br />";
                     $errorMsg .= $this->__($field) . ": " . $this->__($fError);
                 }
                 $errorMsg = substr($errorMsg, 0, strlen($errorMsg) - 1);
                 Mage::log("Error (fieldErrors) - " . $errorMsg);
                 return array('error' => $errorMsg);
             } elseif (isset($parsedResponseArr['globalError']) && $parsedResponseArr['globalError']) {
                 Mage::log("Error (globalError) - " . $parsedResponseArr['globalError']);
                 return array('error' => $parsedResponseArr['globalError']);
             }
         }
         Mage::log("Returning data: " . $parsedResponseArr['data']);
         return array('error' => false, 'data' => $parsedResponseArr['data']);
     } catch (Exception $e) {
         Mage::log("Got error: " . print_r($e, true));
         return array('error' => $this->__($e->getMessage()));
     }
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:49,代码来源:Data.php

示例12: _restFileUpload

    /**
     * Perform a rest post throwing an exception if result failed
     *
     * @param string $method
     * @param array  $options
     * @param array  $defaultOptions
     * @return Zend_Rest_Client_Result
     */
    protected function _restFileUpload($method, $file, $param, array $options, array $defaultOptions = array())
    {
        $options  = $this->_prepareOptions($method, $options, $defaultOptions);

        $client = Zend_Rest_Client::getHttpClient();
        $client->setUri($this->getScribdClient()->getRestClient()->getUri());

        $client->setParameterGet($options);
        $client->setFileUpload($file, $param);
        $response = $client->request('POST');

        if ($response->isError()) {
            $code = $response->extractCode($response->asString());

            /**
             * @see Zym_Service_Scribd_Exception
             */
            require_once 'Zym/Service/Scribd/Exception.php';
            throw new Zym_Service_Scribd_Exception($response->getMessage(), $code);
        }

        return $this->_handleResponse($response);
    }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:31,代码来源:Abstract.php

示例13: __call

 /**
  *
  * @throws apiException
  * @param string $name
  * @param array  $arguments
  * @return DatatypeAbstract objet représentant les données du web service.
  */
 public function __call($name, $arguments)
 {
     $iIdRessource = "index";
     if (count($arguments) != 2) {
         throw new \SitecRESA\Exception\Api("client method calls expect 2 parameter");
     }
     if (!is_array($arguments[1])) {
         throw new \SitecRESA\Exception\Api("client arguments parameter should be an array");
     }
     $aParams = $arguments[1];
     $sVerbe = $arguments[0];
     if (array_key_exists('idRessource', $aParams)) {
         $iIdRessource = $aParams['idRessource'];
         unset($aParams['idRessource']);
     }
     if (!array_key_exists('format', $aParams)) {
         $aParams['format'] = self::FORMAT;
     }
     $aParams['requestHash'] = hash_hmac("sha1", $this->sApiKey . '-' . time(), $this->sSecretKey);
     $aParams['apiKey'] = $this->sApiKey;
     $aParams['timestamp'] = time();
     $aParams['version'] = $this->version;
     $name = self::PREFIX_PATH . $name;
     if ($this->panier && $this->panier instanceof \SitecRESA\Datatype\Panier) {
         $aParams["identifiantPanier"] = $this->panier->id;
     }
     $client = \Zend_Rest_Client::getHttpClient();
     if (count($aParams) > 0) {
         if (!isset($aParams["dateDebut"])) {
             $aParams["dateDebut"] = null;
         }
         if (!isset($aParams["dateFin"])) {
             $aParams["dateFin"] = null;
         }
         $client->setHeaders($aParams);
     }
     switch ($sVerbe) {
         case "post":
             $response = $this->client->restPost($name, $aParams);
             break;
         case "put":
             $response = $this->client->restPut($name . "/" . $iIdRessource, $aParams);
             break;
         case "get":
             $response = $this->client->restGet($name . "/get/" . $iIdRessource, $aParams);
             break;
         case "delete":
             $response = $this->client->restDelete($name . "/" . $iIdRessource);
             break;
         default:
             throw new \SitecRESA\Exception\Api("{$sVerbe} n'est pas une requête HTTP gérée par ce Web Service");
     }
     if ($response->getStatus() == 401) {
         throw new \SitecRESA\Exception\Auth($response->getBody() . " status : " . $response->getStatus(), $response->getStatus());
     }
     if ($response->getStatus() == 412) {
         return $this->doResponse($response->getBody(), $aParams['format']);
         //throw new \SitecRESA\Exception\IO($response->getBody(),$response->getStatus() );
     }
     if ($response->getStatus() == 201) {
         //créé et l'accès est disponible
         return $response->getHeader("Location");
     }
     if ($response->getStatus() == 204) {
         //pas de contenu.
         return;
     }
     if ($response->getStatus() != 200) {
         throw new \SitecRESA\Exception\Api($response->getBody(), $response->getStatus());
     }
     return $this->doResponse($response->getBody(), $aParams['format']);
 }
开发者ID:sitecresa,项目名称:toolkit,代码行数:79,代码来源:Client.php

示例14: logApiCallException

 /**
  * Log API call (request and response)
  * @param \Zend_Rest_Client $client
  * @param \Exception $exception
  * @return void
  */
 public function logApiCallException(\Zend_Rest_Client $client, \Exception $exception)
 {
     $this->info($client->getHttpClient()->getLastRequest());
     $this->err($exception->getMessage());
 }
开发者ID:halk,项目名称:recowise-magento2-demo,代码行数:11,代码来源:Base.php

示例15: setUp

 /**
  *
  * @return void
  */
 public function setUp()
 {
     Zend_Rest_Client::getHttpClient()->setConfig(array('useragent' => 'Zend_Service_Delicious - Unit tests/0.1', 'keepalive' => true));
     $this->_delicious = new Zend_Service_Delicious(self::TEST_UNAME, self::TEST_PASS);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:PrivateDataTest.php


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