Re: [Haskell-cafe] Re: Help using Network.Curl

2008-07-21 Thread Chaddaï Fouché
2008/7/19 Jim Burton [EMAIL PROTECTED]:
 opts = [CurlEncoding text/xml
   , CurlHttpHeaders [X-EBAY-API-COMPATIBILITY-LEVEL=++compatLevel
 , X-EBAY-API-DEV-NAME=++devName
 , X-EBAY-API-APP-NAME=++appName
 , X-EBAY-API-CERT-NAME=++certName
 , X-EBAY-API-CALL-NAME=GeteBayOfficialTime
 , X-EBAY-API-SITEID=0]]

Isn't it : rather than = ? Just saying... (Don't know enough to be
sure I'm thinking about the right thing)

-- 
Jedaï
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Help using Network.Curl

2008-07-21 Thread Jim Burton
At Mon, 21 Jul 2008 13:21:06 +0100,
=?ISO-8859-1?Q?Chadda=EF_Fouch=E9?= wrote:
 
 2008/7/19 Jim Burton [EMAIL PROTECTED]:
  opts = [CurlEncoding text/xml
, CurlHttpHeaders [X-EBAY-API-COMPATIBILITY-LEVEL=++compatLevel
  , X-EBAY-API-DEV-NAME=++devName
  , X-EBAY-API-APP-NAME=++appName
  , X-EBAY-API-CERT-NAME=++certName
  , X-EBAY-API-CALL-NAME=GeteBayOfficialTime
  , X-EBAY-API-SITEID=0]]
 
 Isn't it : rather than = ? Just saying... (Don't know enough to be
 sure I'm thinking about the right thing)

Is is indeed, thanks very much. I also had to change to using
`perform' rather than curlPost before it would work.

Cheers,

Jim 
 -- 
 Jedaï
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Help using Network.Curl

2008-07-19 Thread Jim Burton
I tried to translate that using the Network.Curl docs and ended up with the
following code, but it's not sending the post data correctly (an ebay
api error re an unsupported verb, which I am told means a malformed
request). Any ideas? The code from a perl tutorial (which works for
me, making me think that my problem is just about the right way to
post xml to a web service) follows the haskell version, which is meant
to be a straight translation of that. 

Thanks,

Jim

--

[..skipped definitions of tokens etc..]

opts = [CurlEncoding text/xml
   , CurlHttpHeaders [X-EBAY-API-COMPATIBILITY-LEVEL=++compatLevel
 , X-EBAY-API-DEV-NAME=++devName
 , X-EBAY-API-APP-NAME=++appName
 , X-EBAY-API-CERT-NAME=++certName
 , X-EBAY-API-CALL-NAME=GeteBayOfficialTime
 , X-EBAY-API-SITEID=0]]

body = ?xml version='1.0' encoding='utf-8'? 
   ++ GeteBayOfficialTimeRequest 
xmlns=\urn:ebay:apis:eBLBaseComponents\ 
   ++   RequesterCredentials 
   ++ eBayAuthToken++token++/eBayAuthToken 
   ++   /RequesterCredentials 
   ++ /GeteBayOfficialTimeRequest

url = https://api.sandbox.ebay.com/ws/api.dll;

postData = HttpPost {postName  = body
, contentType  = Just text/xml
, content  = ContentString body
, extraHeaders = []
, showName = Nothing}

opts = []

--also tried using curlPost and setopts then perform... 
main = withCurlDo (do h - initialize
  curlMultiPost url opts [postData]
  )

---

Original perl:

use strict;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Headers;

# define the HTTP header
my $objHeader = HTTP::Headers-new;
$objHeader-push_header('X-EBAY-API-COMPATIBILITY-LEVEL' = '391');
$objHeader-push_header('X-EBAY-API-DEV-NAME' = 'yourdevname');
$objHeader-push_header('X-EBAY-API-APP-NAME' = 'yourappname');
$objHeader-push_header('X-EBAY-API-CERT-NAME' = 'yourcertname');
$objHeader-push_header('X-EBAY-API-CALL-NAME' = 'GeteBayOfficialTime');
$objHeader-push_header('X-EBAY-API-SITEID' = '0');
$objHeader-push_header('Content-Type' = 'text/xml');

# define the XML request
my $request =
?xml version='1.0' encoding='utf-8'? .
GeteBayOfficialTimeRequest xmlns=\urn:ebay:apis:eBLBaseComponents\ .
  RequesterCredentials .
eBayAuthTokenTOKENGoesHERE/eBayAuthToken .
  /RequesterCredentials .
/GeteBayOfficialTimeRequest;

# make the call
my $objRequest = HTTP::Request-new(
  POST,
  https://api.sandbox.ebay.com/ws/api.dll;,
  $objHeader,
  $request
);

# deal with the response
my $objUserAgent = LWP::UserAgent-new;
my $objResponse = $objUserAgent-request($objRequest);
if (!$objResponse-is_error) {
  print $objResponse-content;
}
else {
  print $objResponse-error_as_HTML;
}

--

This is what I get when running my version:

$ ./curlTest 
* About to connect() to api.sandbox.ebay.com port 443 (#0)
*   Trying 66.135.197.133... * connected
* Connected to api.sandbox.ebay.com (66.135.197.133) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* SSL connection using AES256-SHA
* Server certificate:
*subject: /C=US/ST=California/L=San Jose/O=eBay Inc./OU=Site 
Operations/CN=api.sandbox.ebay.com
*start date: 2008-01-25 00:00:00 GMT
*expire date: 2010-03-15 23:59:59 GMT
*common name: api.sandbox.ebay.com (matched)
*issuer: /C=US/O=VeriSign, Inc./OU=VeriSign Trust Network/OU=Terms of 
use at https://www.verisign.com/rpa (c)05/CN=VeriSign Class 3 Secure Server CA
* SSL certificate verify ok.
 POST /ws/api.dll HTTP/1.1
Host: api.sandbox.ebay.com
Accept: */*
Accept-Encoding: text/xml
Content-Length: 1254
Expect: 100-continue
Content-Type: multipart/form-data; 
boundary=7c836e9408cd

 HTTP/1.1 100 Continue
 HTTP/1.1 200 OK
 Date: Sat, 19 Jul 2008 20:04:12 GMT
 Server: Microsoft-IIS/5.0
 X-EBAY-API-POOL-NAME: ___cDRidW90YmtiZWx9b2l3aQ==
 X-EBAY-API-SERVER-NAME: ___dXUucnVlYnVvNzM3KTYzKzc3LTI0KTQxPD8zPTc=
 Content-Type: text/xml
 Content-Length: 330
 X-Cache: MISS from sjcsbagpigw02.sjc.ebay.com, MISS from 
sjcsbagpigw02.sjc.ebay.com
 Connection: close
 
* Closing connection #0
?xml version=1.0 encoding=UTF-8 ?eBayEBayTime2008-07-19
20:04:55/EBayTimeErrorsErrorCode2/CodeErrorClassRequestError/ErrorClassSeverityCode1/SeverityCodeSeveritySeriousError/SeverityLine0/LineColumn0/ColumnShortMessage![CDATA[
Unsupported verb. ]]/ShortMessage/Error/Errors/eBay

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe