From http://stackoverflow.com/questions/6109227/post-json-over-curl-with-basic-authentication