Lots of information, and a very neat project!
Using webhooks would make this SO much simpler, requiring barely any code at all, since the cloud parses the data for you. Check out this project for a great example of that. There's even a neat little tutorial over here.