Dart
Dart
Magento Request with OAuth1.0a Authentication
See more Magento Examples
Demonstrates sending a Magento request with OAuth1.0a authentication. (Using the Magento 1.x REST API)Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final http = CkHttp();
http.oAuth1 = true;
http.oAuthVerifier = '';
http.oAuthConsumerKey = 'MAGENTO_CONSUMER_KEY';
http.oAuthConsumerSecret = 'MAGENTO_CONSUMER_SECRET';
http.oAuthToken = 'MAGENTO__TOKEN';
http.oAuthTokenSecret = 'MAGENTO_TOKEN_SECRET';
http.accept = 'application/json';
final url = 'http://www.inart.com/api/rest/products/store/2?limit=20&page=1';
final String jsonStr;
try {
jsonStr = http.quickGetStr(url);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Response status code = ${http.lastStatus}');
final json = CkJsonObject();
json.load(jsonStr);
json.emitCompact = false;
print(json.emit());
// Use this online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
}