How to access Woocommerce API with Flutter?
6,912
You might wanna use this: https://github.com/lakexyde/dart-woocommerce-api. Though still needs some cleaning but it does work.
Map<String,dynamic> params = {
"url": 'https://example.com',
"consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXXXXX",
"consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXX",
"wpAPI": true,
"version": 'wc/v2'
}
And then:
WooCommerceAPI wooAPI = new WooCommerceAPI(params);
Hope it helps.
Author by
Panahbiru
Updated on December 04, 2022Comments
-
Panahbiru over 1 year
Woocommerce API implements Oauth1 with consumer key/secret.
Here is my code to access WordPress API with Flutter
Future<String> getData() async { var response = await http.get( Uri.encodeFull( "http://jalania.com/wp-json/wp/v2/posts" ), headers: {"Accept": "application/json"}); this.setState(() { data = JSON.decode(response.body); }); }
I've changed the API url to Woocommerce API, http://jalania.com/wp-json/wc/v2/products and got empty responses.
Does anyone know how to access Woocommerce API with flutter?
-
zinger about 5 yearsThe official package is out now. pub.dartlang.org/packages/woocommerce_api
-