So the official documentation is very terse (bad!), particularly for someone who hasn't worked with REST/Oauth in the past. I'm using Magento 1.8.1 CE.
Can somebody provide a simple PHP example of how to use Magento's REST API?
Using their example code (http://www.magentocommerce.com/api/rest/introduction.html) I get two errors:
Message: Undefined index: state
Message: Use of undefined constant OAUTH_AUTH_TYPE_URI - assumed 'OAUTH_AUTH_TYPE_URI'
Thus far I've done:
- Install php oauth extension
- Create at least one product in Magento
- Configure resource permissions for Admin REST user for retrieving all product data for Admin
- Create a Consumer
Any help is greatly appreciated.
EDIT: I narrowed down the problem to (surprise, surprise!) OAuth not working properly. I gave up and changed the Guest roles and attributes to allow all. Then, I tested things to see if they were working by navigating to:
http://yourdomain/api/rest/products
http://yourdomain/api/rest/products/1/images
Everything is indeed working. If/when I figure out how to properly deal with authentication, I'll post the answer.