For our recent new service gotags.co.uk, we wanted to integrate directly with Magento to allow users to directly populate their shopping carts from Instagram. Magento, being the beast of a code base it is (seriously, it's stupidly complex) fortunately has the ability for custom SOAP API's to be built on top of the already existing SOAP API. Our custom endpoint is quite simple; receive an email, a product SKU, some text, and then attempt to populate the relevant customers cart, returning JSON depending on what happened.
So, how's this done? The code is freely available from the module download but here's the in-and-outs of it, skipping all the boring setup stuff.
The most complex part is attempting to find options based on a string given. This string could be blank, completely random text, YOLO, or actual options like "large blue". These human readable options need to be translated into actual option objects, before the product can be added to the cart:
Once you have the product, the next difficulty is in adding the product to the customer cart. Magento carts become stale and are archived off, and there's no simple way of getting the customer cart, stale or not, instead you must do the leg work yourself. To do this, you need to lookup an active quote, and then get the cart from the quote. The below shows how to find the active cart, or create one if not found.
_getStoreId here simply returns the default store id (this is also stupidly complex but not at all interesting).
Download the module from the link above to view the full source code, or if you have a Magento store, you can integrate directly with GOtags and let us do the leg work.