copied over files from CakePHP lib and converted to curl code. Untested.