Screen: ShopSite > Orders

Automatic XML Orders Download

Note:

The information on this page applies to Orders only. For information on automated XML uploads and downloads of Products or Pages, see Database Automated XML Upload/Download.

You can use a merchant-supplied program to automatically download a store’s orders as an XML-formatted text file. This help page describes the programmatic interface; the XML DTD is described on Orders Download XML Format.

Your orders download program must send a request to a ShopSite CGI program (db_xml.cgi) and provide the merchant’s user ID and password to start the download. To keep order information secure, the ShopSite CGI program should be invoked through a secure connection (https). If the connection is not secure, customer credit card information will not be included in the download.

The db_xml.cgi program can accept these optional parameters:

While it is possible to use startorder and endorder or startdate and enddate to download a specific set of orders, you do not have to use both the start and end value. You could, for example, use startdate without enddate to download all the orders that have come in since the last time you downloaded orders.

The db_xml.cgi will output the following line, followed by the XML order information:

Content-type: application/x-www-form-urlencoded\n\n

Example Program

This simple example program uses a non-secure connection to request order information, starting with order number 1962. Because the CGI directory on the server requires authentication, the program sends the user ID and password in encrypted form. This program does not process the XML, so it does not test the response values (Success or Failure).

if ((msg_socket = getconnection("mystore.com",80)) == -1)
{
  printf("Big trouble, no socket connection\n");
  exit(1);
}

    /* create the HTTP header */
sprintf(send_msg,
  "GET /cgi-bin/ss/db_xml.cgi?startorder=1962 HTTP/1.0\n"
  "Host: mystore.com:80\r\n"
  "Authorization: Basic ZGFycmVuOmRhcnJlbg==\r\n\n"); /* userid:password has been encrypted using mimencode.*/

    /* send the HTTP header */
count = send(msg_socket, send_msg, strlen(send_msg),0);

    /* loop to receive order info */
while (count = recv(msg_socket, buf, 2048, 0))
{
  buf[count] = '\0';
  printf("%s",buf); /* since just testing write the order info to the screen */

    /* Here is where you would create a buffer /*
    /* containing all the order info */
    /* and then process that information */
}

close(msg_socket);

The getconnection() function creates a socket link to the specified host on port 80. Once the socket connection has been established the program will "send" the HTTP header that specifies the CGI to invoked along with any parameters (in this case startorder=1962 for the starting order to download), the Host and the Authorization which is needed because the CGI is in a userid/password protected web server directory.


ShopSite Help and Resource Center
Last updated: March 01, 2010
Give Feedback


ShopSite Shopping Cart Software