ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 4850


Ignore:
Timestamp:
Dec 26, 2007, 2:22:00 PM (12 years ago)
Author:
ebihara
Message:

#1621:レビューのプロキシ対応コードの取り込み(とりあえず2.10時点のライブラリ対応版)

Location:
OpenPNE/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/trunk/lib/include/Services/Amazon.php

    r2 r4850  
    107107    */
    108108    var $_baseurl = null;
     109 
     110   /**
     111    * The proxy parameters to be used by HTTP_Request
     112    *
     113    * @access private
     114    * @var    string $_proxy_host
     115    * @var    int    $_proxy_port
     116    * @var    string $_proxy_user
     117    * @var    string $_proxy_pass
     118    */
     119    var $_proxy_host = null;
     120    var $_proxy_port = null;
     121    var $_proxy_user = null;
     122    var $_proxy_pass = null;
    109123
    110124    /**
     
    234248    function getLocale() {
    235249        return $this->_locale;
     250    }
     251   
     252   /**
     253    * Sets a proxy to be used by HTTP_Request
     254    *
     255    * @param string     Proxy host
     256    * @param int        Proxy port
     257    * @param string     Proxy username
     258    * @param string     Proxy password
     259    * @access public
     260    */
     261    function setProxy($host, $port = 8080, $user = null, $pass = null)
     262    {
     263        $this->_proxy_host = $host;
     264        $this->_proxy_port = $port;
     265        $this->_proxy_user = $user;
     266        $this->_proxy_pass = $pass;
    236267    }
    237268   
     
    769800        // request for the URL.
    770801        $http = &new HTTP_Request($url);
     802        if ($this->_proxy_host) $http->setProxy($this->_proxy_host, $this->_proxy_port, $this->_proxy_user, $this->_proxy_pass);
    771803        $http->addHeader('User-Agent', 'Services_Amazon/' . $this->getApiVersion());
    772804        $http->sendRequest();
  • OpenPNE/trunk/webapp/lib/db/review.php

    r4272 r4850  
    9797    include_once 'Services/Amazon.php';
    9898    $amazon =& new Services_Amazon(AMAZON_TOKEN, AMAZON_AFFID, AMAZON_LOCALE, AMAZON_BASEURL);
     99    $amazon->setLocale(AMAZON_LOCALE);
     100    if (OPENPNE_USE_HTTP_PROXY) $amazon->setProxy(OPENPNE_HTTP_PROXY_HOST, OPENPNE_HTTP_PROXY_PORT);
    99101    $products = $amazon->searchKeyword($keyword, $category, $page);
    100102    if (PEAR::isError($products)) {
     
    131133    include_once 'Services/Amazon.php';
    132134    $amazon =& new Services_Amazon(AMAZON_TOKEN, AMAZON_AFFID, AMAZON_LOCALE, AMAZON_BASEURL);
     135    $amazon->setLocale(AMAZON_LOCALE);
     136    if (OPENPNE_USE_HTTP_PROXY) $amazon->setProxy(OPENPNE_HTTP_PROXY_HOST, OPENPNE_HTTP_PROXY_PORT);
    133137    $keyword = mb_convert_encoding($keyword, "UTF-8", "auto");
    134138
Note: See TracChangeset for help on using the changeset viewer.