kenko.com

|
<?
    require_once( "../config/all.php" );
    require_once( PATH_TOOL . "DBI.class.php" );
    require_once( "SOAP/Client.php" );

    class Batch_WEBServiceKenkocom {

        var $_dbi = null;
        var $_log_date = null;
        var $_log_flag = false;
        var $_tmp_file_name = null;
        var $_item_code = null;

        function Batch_WEBServiceKenkocom( $test_log, $date ) {
            $this->_dbi = new DBI();
            $this->_log_date = $date;
            $this->_log_flag = $test_log;
        }

        function start(){
            $log_text = "===== Batch_WEBServiceKenkcom START. ===== ===== ===== ===== =====";
            $this->_dbi->truncateLog( $log_text, $this->_log_flag );

            $wsdl = 'http://wsc.kenko.com/wsdl/aff.wsdl';
            $soap_options = array();
            $access_key = 'KWSA00219';
            $secure = '';  // 追加
            $associate = '';

            $action = 'ItemLookup';

            $this->_item_code = "X755470H";
            $this->_tmp_file_name = "./targets/tmp/item" . $this->_item_code . ".xml";

            $request = array(
                'ItemId'            => $this->_item_code,
                'Operation'            => $action,
                'ResponseGroup'        => "Offers"
            );

            $params = array(
                'Service'            => "KWSECommerceService",
                'AWSAccessKeyId'    => $access_key,
                'AssociateTag'        => $associate,
                'Request'            => $request
            );

            $soap = new SoapClient($wsdl, $soap_options);

            try {
                // ヘッダ追加:ここから
                // create signature
                $timestamp = gmstrftime('%Y-%m-%dT%TZ', $_SERVER['REQUEST_TIME']);
                $signature = base64_encode(hash_hmac('sha256', ($action . $timestamp), $secure, true));

                // create soap header
                $namespace = 'http://wsc.kenko.com/axis/services/AWSECommerceService';
                $header_data = array(
                    'AWSAccessKeyId'    => $access_key,
                    );

                $headers = array();
                foreach ($header_data as $name => $val) {
                  $headers[] = new SoapHeader($namespace, $name, $val);
                }

                $soap->__setSoapHeaders($headers);
                // ヘッダ追加:ここまで

                $ret = $soap->$action($params);
            } catch( SoapFault $e ) {
                print_r($e);
                exit(0);
            }

        }

        function end(){
            $log_text = "===== Batch_WEBServiceKenkcom END. ===== ===== ===== ===== =====";
            $this->_dbi->insertLog( $log_text, $this->_log_flag );
            $this->_dbi->closeDB();
        }
    }

?>

'TIP' 카테고리의 다른 글

IE 버전별 테스트  (0) 2010.03.23
ss  (0) 2010.03.03
일본 부동산  (0) 2009.11.22
제로보드4  (0) 2009.11.06
홈페이지 탬플릿  (0) 2009.11.05
And