Permalink
Browse files

NODEJS-1103: Add the usage of generic in README.md.

  • Loading branch information...
peri18 committed Nov 4, 2013
1 parent b99b015 commit 5d940cd5d1e5a3f834a139f3a96cab60e2183790
Showing with 37 additions and 2 deletions.
  1. +37 −2 README.md
View
@@ -9,7 +9,7 @@ You can install it using npm.
Usage
-----
-Example, do ACS user login:
+Example 1, do ACS user login:
- var ACS = require('acs-node');
- function login(req, res) {
@@ -31,7 +31,42 @@ Example, do ACS user login:
- });
- }
-More examples and how to use a generic method, please look up in the folder test.
+Example 2, a generic method show how to operate an ACS user:
+
+- var ACS = require('acs-node');
+- var sdk = ACS.initACS('', '');
+- var user_id = null;
+- var filePath = "/Users/bill/2012-07.xls";
+- var photoPath = "/Users/bill/photo.JPG";
+- var useSecure = true;
+- sdk.sendRequest('users/create.json', 'POST', {username:'test1', password:'test1', password_confirmation:'test1'}, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- user_id = data.response.users[0].id;
+- sdk.sendRequest('files/create.json', 'POST', {name: 'abcd', file: filePath}, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- sdk.sendRequest('users/logout.json', 'DELETE',null, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- sdk.sendRequest('users/login.json', 'POST', {login:'test1', password:'test1'}, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- sdk.sendRequest('photos/create.json', 'POST', {photo: photoPath}, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- sdk.sendRequest('users/update.json', 'PUT', {first_name: 'abcd'}, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- sdk.sendRequest('users/delete.json', 'DELETE', null, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- sdk.sendRequest('users/show.json', 'GET', {'user_id': user_id}, function(data){
+- console.log(JSON.stringify(data, null, 2));
+- }, useSecure);
+- }, useSecure);
+- }, useSecure);
+- }, useSecure);
+- }, useSecure);
+- }, useSecure);
+- }, useSecure);
+- }, useSecure);
+
+
+More examples, please look up in the folder test.
Legal

0 comments on commit 5d940cd

Please sign in to comment.