osCmax v2.5 User Manual
Results 1 to 6 of 6

Notice from USPS

This is a discussion on Notice from USPS within the osCommerce 2.2 Discussion forums, part of the osCommerce 2.2 Forums category; I received an email from the usps web tool api dept. saying: As of September 30, 2006, you will be ...

      
  1. #1
    New Member
    Join Date
    Oct 2004
    Posts
    27
    Rep Power
    0


    Default Notice from USPS

    I received an email from the usps web tool api dept. saying:

    As of September 30, 2006, you will be required to communicate via
    https://, instead of http://, for a total of 46 USPS Web Tools APIs.
    This change will also require you to change the Web Tools server called
    from production.shippingapis.com to secure.shippingapis.com.



    After September 30, 2006, the http:// instances of impacted APIs shall
    no longer be accessible.

    Does anyone know if this will affect any of the usps modules or contributions? I am using usps methods.

    Thanks!

  2. #2
    Lurker
    Join Date
    Mar 2006
    Posts
    3
    Rep Power
    0


    Default RE: Notice from USPS

    I received the same email. I hope some body will come up with the answer.

  3. #3
    jpf
    jpf is offline
    osCMax Testing Team
    jpf's Avatar
    Join Date
    Sep 2003
    Location
    Manitoba, Canada
    Posts
    2,699
    Rep Power
    22


    Default RE: Notice from USPS

    You have to possably copy and modify http_client.php to https_client.php then in usps.php modify httpClient(....) httpsClient(....)

    That should be a start. Possably in the next few weeks some might post an update to the orginal contribution.
    JPF - osCMax Fourm Moderator - To contact, post on the forum or click here
    Try out our osCMax at: Live Catalog Demo
    Limited access Admin: Live Admin Demo
    Feel free to add products they way you want and then purchase them -=+=- Sorry nothing will be billed or shipped!

  4. #4
    New Member lane's Avatar
    Join Date
    Dec 2003
    Posts
    11
    Rep Power
    0


    Default Re: RE: Notice from USPS

    Quote Originally Posted by jpf
    You have to possably copy and modify http_client.php to https_client.php then in usps.php modify httpClient(....) httpsClient(....)

    That should be a start. Possably in the next few weeks some might post an update to the orginal contribution.
    I did some quick tests on this and didn't get good results. While it connects to the usps site fine, it returns an error which I have not had time to investigate. Could be that since the rate api is not listed it is also not available via the new secure url.

    My modified connection is:
    Code:
          $usps_server = 'secure.shippingapis.com';
          $http = new httpClient();
          if ($http->Connect($usps_server, 'SSL')) {
    and here is my modified http_client.php code that allows connecting via https:
    Code:
    <?php
    /*
      $Id: http_client.php,v 1.5 2005/08/16 20:56:40 lane Exp $
    
      osCommerce, Open Source E-Commerce Solutions
      http://www.oscommerce.com
    
      Copyright (c) 2002 osCommerce
    
      Released under the GNU General Public License
    
      Copyright 2001 Leo West <west_leo@yahoo-REMOVE-.com> Net_HTTP_Client v0.6
    
      Minimal Example:
    
      $http = new httpClient();
      $http->Connect("somehost", 80) or die("Connect problem");
      $status = $http->Get("/index.html");
      if ($status != 200) {
        die("Problem : " . $http->getStatusMessage());
      } else {
        echo $http->getBody();
      }
      $http->Disconnect();
    
      Persistent Example:
    
      $http = new httpClient("dir.yahoo.com", 80);
      $http->addHeader("Host", "dir.yahoo.com");
      $http->addHeader("Connection", "keep-alive");
    
      if ($http->Get("/Reference/Libraries/") == 200) $page1 = $http->getBody();
      if ($http->Get("/News_and_Media/") == 200 ) $page2 = $http->getBody();
      $http->disconnect();
      
      Lane Roathe (IFD.COM) : Added - substitute the port value (ie, 80) with 'SSL' to use a secure connection (ie, https) on port 443
    */
    
      class httpClient {
        var $url; // array containg server URL, similar to parseurl() returned array
        var $reply; // response code
        var $replyString; // full response
        var $protocolVersion = '1.1';
        var $requestHeaders, $requestBody;
        var $socket = false;
    // proxy stuff
        var $useProxy = false;
        var $proxyHost, $proxyPort;
    
    /**
     * httpClient constructor
     * Note: when host and port are defined, the connection is immediate
     * @seeAlso connect
     **/
        function httpClient($host = '', $port = '') {
          if (tep_not_null($host)) {
            $this->connect($host, $port, $type);
          }
        }
    
    /**
     * turn on proxy support
     * @param proxyHost proxy host address eg "proxy.mycorp.com"
     * @param proxyPort proxy port usually 80 or 8080
     **/
        function setProxy($proxyHost, $proxyPort) {
          $this->useProxy = true;
          $this->proxyHost = $proxyHost;
          $this->proxyPort = $proxyPort;
        }
    
    /**
     * setProtocolVersion
     * define the HTTP protocol version to use
     * @param version string the version number with one decimal: "0.9", "1.0", "1.1"
     * when using 1.1, you MUST set the mandatory headers "Host"
     * @return boolean false if the version number is bad, true if ok
     **/
        function setProtocolVersion($version) {
          if ( ($version > 0) && ($version <= 1.1) ) {
            $this->protocolVersion = $version;
            return true;
          } else {
            return false;
          }
        }
    
    /**
     * set a username and password to access a protected resource
     * Only "Basic" authentication scheme is supported yet
     * @param username string - identifier
     * @param password string - clear password
     **/
        function setCredentials($username, $password) {
          $this->addHeader('Authorization', 'Basic ' . base64_encode($username . ':' . $password));
         }
    
    /**
     * define a set of HTTP headers to be sent to the server
     * header names are lowercased to avoid duplicated headers
     * @param headers hash array containing the headers as headerName => headerValue pairs
     **/
        function setHeaders($headers) {
          if (is_array($headers)) {
            reset($headers);
            while (list($name, $value) = each($headers)) {
              $this->requestHeaders[$name] = $value;
            }
          }
        }
    
    /**
     * addHeader
     * set a unique request header
     * @param headerName the header name
     * @param headerValue the header value, ( unencoded)
     **/
        function addHeader($headerName, $headerValue) {
          $this->requestHeaders[$headerName] = $headerValue;
        }
    
    /**
     * removeHeader
     * unset a request header
     * @param headerName the header name
     **/
        function removeHeader($headerName) {
          unset($this->requestHeaders[$headerName]);
        }
    
    /**
     * Connect
     * open the connection to the server
     * @param host string server address (or IP)
     * @param port string server listening port - defaults to 80
     * @return boolean false is connection failed, true otherwise
     **/
        function Connect($host, $port = '') {
    	 	if( $port == 'SSL' )
    		{
    	      $this->url['scheme'] = 'HTTPS';   //Lane Roathe (IFD.COM) - allow ssl connections when port is SSL
    	      $this->url['port'] = 443;
    		}
    		else
    		{
    	      $this->url['scheme'] = 'HTTP';
    	      if (tep_not_null($port)) $this->url['port'] = $port;
    		}
    
          $this->url['host'] = $host;
    
          return true;
        }
    
    /**
     * Disconnect
     * close the connection to the  server
     **/
        function Disconnect() {
          if ($this->socket) fclose($this->socket);
        }
    
    /**
     * head
     * issue a HEAD request
     * @param uri string URI of the document
     * @return string response status code (200 if ok)
     * @seeAlso getHeaders()
     **/
        function Head($uri) {
          $this->responseHeaders = $this->responseBody = '';
    
          $uri = $this->makeUri($uri);
    
          if ($this->sendCommand('HEAD ' . $uri . ' HTTP/' . $this->protocolVersion)) {
            $this->processReply();
          }
    
          return $this->reply;
        }
    
    /**
     * get
     * issue a GET http request
     * @param uri URI (path on server) or full URL of the document
     * @return string response status code (200 if ok)
     * @seeAlso getHeaders(), getBody()
     **/
        function Get($url) {
          $this->responseHeaders = $this->responseBody = '';
    
          $uri = $this->makeUri($url);
    
          if ($this->sendCommand('GET ' . $uri . ' HTTP/' . $this->protocolVersion)) {
            $this->processReply();
          }
    
          return $this->reply;
        }
    
    /**
     * Post
     * issue a POST http request
     * @param uri string URI of the document
     * @param query_params array parameters to send in the form "parameter name" => value
     * @return string response status code (200 if ok)
     * @example 
     * $params = array( "login" => "tiger", "password" => "secret" );
     * $http->post( "/login.php", $params );
     **/
        function Post($uri, $query_params = '') {
          $uri = $this->makeUri($uri);
    
          if (is_array($query_params)) {
            $postArray = array();
            reset($query_params);
            while (list($k, $v) = each($query_params)) {
              $postArray[] = urlencode($k) . '=' . urlencode($v);
            }
    
            $this->requestBody = implode('&', $postArray);
          }
    
    // set the content type for post parameters
          $this->addHeader('Content-Type', 'application/x-www-form-urlencoded');
    
          if ($this->sendCommand('POST ' . $uri . ' HTTP/' . $this->protocolVersion)) {
            $this->processReply();
          }
    
          $this->removeHeader('Content-Type');
          $this->removeHeader('Content-Length');
          $this->requestBody = '';
    
          return $this->reply;
        }
    
    /**
     * Put
     * Send a PUT request
     * PUT is the method to sending a file on the server. it is *not* widely supported
     * @param uri the location of the file on the server. dont forget the heading "/"
     * @param filecontent the content of the file. binary content accepted
     * @return string response status code 201 (Created) if ok
     * @see RFC2518 "HTTP Extensions for Distributed Authoring WEBDAV"
     **/
        function Put($uri, $filecontent) {
          $uri = $this->makeUri($uri);
          $this->requestBody = $filecontent;
    
          if ($this->sendCommand('PUT ' . $uri . ' HTTP/' . $this->protocolVersion)) {
            $this->processReply();
          }
    
          return $this->reply;
        }
    
    /**
     * getHeaders
     * return the response headers
     * to be called after a Get() or Head() call
     * @return array headers received from server in the form headername => value
     * @seeAlso get, head
     **/
        function getHeaders() {
          return $this->responseHeaders;
        }
    
    /**
     * getHeader
     * return the response header "headername"
     * @param headername the name of the header
     * @return header value or NULL if no such header is defined
     **/
        function getHeader($headername) {
          return $this->responseHeaders[$headername];
        }
    
    /**
     * getBody
     * return the response body
     * invoke it after a Get() call for instance, to retrieve the response
     * @return string body content
     * @seeAlso get, head
     **/
        function getBody() {
          return $this->responseBody;
        }
    
    /**
     * getStatus return the server response's status code
     * @return string a status code
     * code are divided in classes (where x is a digit)
     *  - 20x : request processed OK
     *  - 30x : document moved
     *  - 40x : client error ( bad url, document not found, etc...)
     *  - 50x : server error 
     * @see RFC2616 "Hypertext Transfer Protocol -- HTTP/1.1"
     **/
        function getStatus() {
          return $this->reply;
        }
    
    /** 
     * getStatusMessage return the full response status, of the form "CODE Message"
     * eg. "404 Document not found"
     * @return string the message 
     **/
        function getStatusMessage() {
          return $this->replyString;
        }
    
    /**
     * @scope only protected or private methods below
     **/
    
    /** 
     * send a request
     * data sent are in order
     * a) the command
     * b) the request headers if they are defined
     * c) the request body if defined
     * @return string the server repsonse status code
     **/
        function sendCommand($command) {
          $this->responseHeaders = array();
          $this->responseBody = '';
    
    // connect if necessary
          if ( ($this->socket == false) || (feof($this->socket)) ) {
            if ($this->useProxy) {
              $host = $this->proxyHost;
              $port = $this->proxyPort;
            } else {
              $host = $this->url['host'];
              $port = $this->url['port'];
            }
    
            if (!tep_not_null($port)) $port = 80;
    
            if (!$this->socket = fsockopen($host, $port, $this->reply, $this->replyString)) {
              return false;
            }
    
            if (tep_not_null($this->requestBody)) {
              $this->addHeader('Content-Length', strlen($this->requestBody));
            }
    
            $this->request = $command;
            $cmd = $command . "\r\n";
            if (is_array($this->requestHeaders)) {
              reset($this->requestHeaders);
              while (list($k, $v) = each($this->requestHeaders)) {
                $cmd .= $k . ': ' . $v . "\r\n";
              }
            }
    
            if (tep_not_null($this->requestBody)) {
              $cmd .= "\r\n" . $this->requestBody;
            }
    
    // unset body (in case of successive requests)
            $this->requestBody = '';
    
            fputs($this->socket, $cmd . "\r\n");
    
            return true;
          }
        }
    
        function processReply() {
          $this->replyString = trim(fgets($this->socket, 1024));
    
          if (preg_match('|^HTTP/\S+ (\d+) |i', $this->replyString, $a )) {
            $this->reply = $a[1];
          } else {
            $this->reply = 'Bad Response';
          }
    
    //get response headers and body
          $this->responseHeaders = $this->processHeader();
          $this->responseBody = $this->processBody();
    
          return $this->reply;
        }
    
    /**
     * processHeader() reads header lines from socket until the line equals $lastLine
     * @scope protected
     * @return array of headers with header names as keys and header content as values
     **/
        function processHeader($lastLine = "\r\n") {
          $headers = array();
          $finished = false;
    
          while ( (!$finished) && (!feof($this->socket)) ) {
            $str = fgets($this->socket, 1024);
            $finished = ($str == $lastLine);
            if (!$finished) {
              list($hdr, $value) = split(': ', $str, 2);
    // nasty workaround broken multiple same headers (eg. Set-Cookie headers) @FIXME 
              if (isset($headers[$hdr])) {
                $headers[$hdr] .= '; ' . trim($value);
              } else {
                $headers[$hdr] = trim($value);
              }
            }
          }
    
          return $headers;
        }
    
    /**
     * processBody() reads the body from the socket
     * the body is the "real" content of the reply
     * @return string body content 
     * @scope private
     **/
        function processBody() {
          $data = '';
          $counter = 0;
    
          do {
            $status = socket_get_status($this->socket);
            if ($status['eof'] == 1) {
              break;
            }
    
            if ($status['unread_bytes'] > 0) {
              $buffer = fread($this->socket, $status['unread_bytes']);
              $counter = 0;
            } else {
              $buffer = fread($this->socket, 128);
              $counter++;
              usleep(2);
            }
    
            $data .= $buffer;
          } while ( ($status['unread_bytes'] > 0) || ($counter++ < 10) );
    
          return $data;
        }
    
    /**
     * Calculate and return the URI to be sent ( proxy purpose )
     * @param the local URI
     * @return URI to be used in the HTTP request
     * @scope private
     **/
        function makeUri($uri) {
          $a = parse_url($uri);
    
          if ( (isset($a['scheme'])) && (isset($a['host'])) ) {
            $this->url = $a;
          } else {
            unset($this->url['query']);
            unset($this->url['fragment']);
            $this->url = array_merge($this->url, $a);
          }
    
          if ($this->useProxy) {
            $requesturi = $this->url['scheme'] . '://' . $this->url['host'] . (empty($this->url['port']) ? '' : ':' . $this->url['port']) . $this->url['path'] . (empty($this->url['query']) ? '' : '?' . $this->url['query']);
          } else {
            $requesturi = $this->url['path'] . (empty($this->url['query']) ? '' : '?' . $this->url['query']);
          }
    
          return $requesturi;
        }
      }
    ?>

  5. #5
    Member Dubious's Avatar
    Join Date
    Feb 2006
    Posts
    43
    Rep Power
    0


    Default Re: Notice from USPS

    Bump! I've got a client asking about this, and it's going to change over to secure server in a week!

    This is of concern to any of us who use USPS.

    Dubious

  6. #6
    osCMax Developer

    michael_s's Avatar
    Join Date
    Jul 2002
    Location
    Phoenix, AZ
    Posts
    19,907
    Rep Power
    568


    Default Re: Notice from USPS

    Actually, this does not apply to the USPS mod that osCMax uses as it does not use any of the methods that are changing. The method that osCMax uses does not transmit any customer data, and is not going to be affected by the change.
    Michael Sasek
    osCMax Developer


    osCmax Installation Service
    - Have our professionals install osCmax on your server - same day service!
    osCmax 2.5 User Manual - the must have beginners guide to osCmax v2.5

    Stay Up To Date with everything osCMax:
    Free osCmax Newsletters - Security notices, New Releases, osCMax News
    osCmax on Twitter - Up to the minute info as it happens. Know it first.

    osCmax Documentation

Similar Threads

  1. Email order notice to admin
    By razz2 in forum osCmax v1.7 Discussion
    Replies: 3
    Last Post: 02-10-2005, 07:00 AM
  2. Privacy notice not working
    By afguns in forum osCmax v1.7 Discussion
    Replies: 3
    Last Post: 01-14-2004, 09:36 PM
  3. USPS trouble anyone?
    By dougnyc in forum osCmax v1.7 Discussion
    Replies: 1
    Last Post: 12-05-2003, 09:32 PM
  4. USPS Problems
    By XTSCrankN in forum osCommerce 2.2 Installation Help
    Replies: 1
    Last Post: 02-20-2003, 06:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •