Had the exact same idea thinking it over last night as I didn't like all the code duplication either. And the idea of using CURL's instead of strings is something that has been discussed many times before in the past, and is still a good idea. But the implementation is non-trivial obviously.