I'm developing a toy program which uses the Google URL shortener API. To shorten a URL, you need to send this request:
POST https://www.googleapis.com/urlshortener/v1/url
Content-Type: application/json
{"longUrl": "http://www.google.com/"}
and you will get this as response:
{
"kind": "urlshortener#url",
"id": "http://goo.gl/fbsS",
"longUrl": "http://www.google.com/"
}
At first I use Network.HTTP, but found it doesn't support HTTPS, and Google's API only supports HTTPS. So I turn to Network.Curl. I find that there's a convenient function for HTTP GET
curlGetString :: URLString -> [CurlOption] -> IO (CurlCode, String)
but there's no such a function for HTTP POST. Even worse, I can't find a way to get the response data of HTTP POST. All I know is that I can issue a HTTP POST request using
curlPost :: URLString -> [String] -> IO ()
Could anyone show me a way out? Thanks.