[Haskell-cafe] Help using Network.Curl

Jim Burton jim at sdf-eu.org
Fri Jul 18 20:16:46 EDT 2008


I want to convert this code (a Hello World with the ebay API)
 to the curl binding in the hope that it will handle SSL and
 redirections etc better. Can someone give me some pointers please, or
 a link to an example? I haven't used libcurl or Network.Curl and
 can't find anything helpful...Thanks!

-----------------
import Network.URI
import Network.HTTP
import Network.Browser
import Data.Maybe (fromJust)

mkRequest :: Request
mkRequest = Request {
              rqURI     = fromJust (parseURI "https://api.sandbox.ebay.com/ws/api.dll")
            , rqMethod  = POST
            , rqBody    = body
            , rqHeaders = headers
            }

headers :: [Header]
headers = [Header HdrContentType "text/xml"
          , Header (HdrCustom "X-EBAY-API-COMPATIBILITY-LEVEL") "391"
          , Header (HdrCustom "X-EBAY-API-DEV-NAME") "DevName"
          , Header (HdrCustom "X-EBAY-API-APP-NAME") "AppName"
          , Header (HdrCustom "X-EBAY-API-CERT-NAME") "CertName"
          , Header (HdrCustom "X-EBAY-API-CALL-NAME") "GeteBayOfficialTime"
          , Header (HdrCustom "X-EBAY-API-SITEID") "0"
          ]

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

main = do (_, resp) <- browse (request mkRequest)
          print resp


More information about the Haskell-Cafe mailing list