Order API

General ShopSite user discussion

Order API

Postby hollettster » Mon Apr 09, 2007 9:27 am

I don't know Perl and don't really want to learn it. What I want to do is get an XML file downloaded from every order (1 order in an xml). I want to then parse the XML and take its values and I have to pass them to 2 seperate databases (I already have this part done). I can only figure out how to download 1 xml from the web interface(contains every order) and I can then parse it. I want to automate this process. Does anyone have any example code I can use? Thanks in advance for the help.
hollettster
 
Posts: 6
Joined: Mon Apr 09, 2007 7:58 am

Postby robm » Mon Apr 09, 2007 12:30 pm

An order API script would have access to all the order variables from ShopSite, but they would not be in an XML format. Your script would need to build an XML file and then pass it to your application.

Have you looked at the Auto XML download feature of ShopSite Pro?
http://www.shopsite.com/help/8.2/en-US/ ... -auto.html

This would allow you to have a script query the DB at any time, and you can download any number of orders. Your order API script could trigger an XML download for just the order number that was just ordered. The docs page above has example code as well.
robm
 
Posts: 463
Joined: Fri Aug 04, 2006 5:46 pm
Location: Connecticut

I have read that

Postby hollettster » Mon Apr 09, 2007 1:27 pm

The example in the help file is not a huge help because i do not know whether it is a PHP, Perl or what. Where do I put in my userid and password etc.. The document here is not real clear at all. Can you give me an example?
hollettster
 
Posts: 6
Joined: Mon Apr 09, 2007 7:58 am

Postby robm » Mon Apr 09, 2007 1:33 pm

Try this link for perl examples and code to help with u/p issues:

http://www.shopsite.com/help/8.2/en-US/ ... L_SDK.html
robm
 
Posts: 463
Joined: Fri Aug 04, 2006 5:46 pm
Location: Connecticut

Can i pass the user id and password via the url?

Postby hollettster » Sat Apr 14, 2007 9:37 pm

Can I pass the userid and password via the url? I want to automate this but in order to use the CGIwrap, I need to login everytime manually.
hollettster
 
Posts: 6
Joined: Mon Apr 09, 2007 7:58 am

Postby robm » Sat Apr 14, 2007 10:06 pm

Yes, you should be able to use the URL format:
https://USERNAME:PASSWORD@your_domain.com/...

or I believe the SDK explains another encrypted method as well.
robm
 
Posts: 463
Joined: Fri Aug 04, 2006 5:46 pm
Location: Connecticut

That doesn't seem to work.

Postby hollettster » Sun Apr 15, 2007 8:11 pm

I am using https://username:password@dmain.com/cgi ... ersion=7.1

I changed some of the stuff above but throws an error in IE saying Windows cannt find.
hollettster
 
Posts: 6
Joined: Mon Apr 09, 2007 7:58 am

Postby robm » Sun Apr 15, 2007 8:17 pm

IE does not support http u/p URL's any longer. Try it in Firefox and see if you get output. If you're using an API, you would be making the URL call via wget, curl, direct post/get, etc... which is different than running it from a web browser.
robm
 
Posts: 463
Joined: Fri Aug 04, 2006 5:46 pm
Location: Connecticut

Postby loren_d_c » Sun Apr 15, 2007 8:58 pm

I bet this wget example would work (assuming you had wget on the computer you are running this command from, which you probably wouldn't if you were running it from Windows but would if you were running it from a Linux computer):


Code: Select all
wget https://www.mydomain.com/cgi-bin/ss/db_xml.cgi?startorder=5000053&endorder=5000053&version=7.1  --http-user=myusername --http-passwd=mypasswd --output-document=/local/path/where/I/want/my/file.xml --quiet


Or maybe some Perl code like this might do the trick if run on a computer with Perl installed (you can get Perl for Windows, I believe) if you also have the IO::Socket and MIME::Base64 Perl modules installed:

Code: Select all
#!/usr/bin/perl

### settings
$usernamecolonpasswd = "myusername:mypasswd";
$domainname = "www.mydomainname.com";
$bocgipath = "/cgi-bin/ss";
$startorder = "5000053";
$endorder = "5000053";
$ssversion = "7.1";

### program
use IO::Socket;
use MIME::Base64;

$socket = IO::Socket::INET->new(Proto => 'tcp',
                                PeerAddr => $domainname,
                                PeerPort => 80,
                                Timeout => 10,
                                Type => SOCK_STREAM)
or die "Couldn't connect to $domainname on port 80!";

$encoded = encode_base64($usernamecolonpasswd);

print $socket ("GET
$bocgipath/db_xml.cgi?startorder=$startorder&endorder=$endorder&version=$ssversion
HTTP/1.1\nHost: $domainname\nAuthorization: Basic $encoded\n\n");

$answer = <$socket>;

close($socket);

print $answer;

1;


Note that this example uses the regular (non-secure) http port 80 instead of the secure https port 443 (and as a result, ShopSite will not provide credit card info in the downloaded order info) because I'm not sure if the IO::Socket Perl module supports SSL or not, and off the top of my head I don't know what other module you would use to get the same kind of functionality with SSL support. But hey it's just sample code and completely unsupported so you should be reviewing Perl documentation to complete it anyway.

Good luck.

-Loren
loren_d_c
 
Posts: 2572
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere


Return to User Forum

Who is online

Users browsing this forum: No registered users and 98 guests