从 offset 开始,共 count 条
-
URL: /news/list/offset=:offset&&count=:count
-
Type: Get
-
Response 200
{ "data": [ { "group_id": "id", "author": "author", "time": "4412000000", "title": "title", "images_info": "json string", "comments": 0 }, { "group_id": "id", "author": "author", "time": "4412000000", "title": "title", "images_info": "json string", "comments": 0 } ] }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/news/list/offset=0&count=10"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/news/list/offset=0&count=10') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /news/content/id=:newsID'
-
Type: Get
-
Response 200
{ "data": "content" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/news/content/id=111sdfsd111'"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/news/content/id=111sdfsd111') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /comment/newsID=:newsID
-
Type: GET
-
Response 200
{ "comments": [ { "commentID": 1, "newsID": "newsID", "userID": "username", "stars": 123, "time": "time" }, { "commentID": 2, "newsID": "newsID", "userID": "username", "stars": 123, "time": "time" } ] }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/comment/newsID=newsID"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/comment/newsID=newsID') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /comment/username=:username
-
Type: GET
-
Response 200
{ "data": [ { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 }, { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 } ] }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/comment/username=username"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/comment/username=username') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /comment
-
Type: POST
-
Data
{ "newsID": "newsID", "userID": "username", "time": "time", "content": "content" }
-
Response 200
{ "data": 123 }
-
Response 400
{ "message": "err msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/user/login"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"username=test&password=test"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/comment', { userID: "username", newsID: "newsID", time: "time", content: "content" }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /star/comments/username=:username
-
Type: GET
-
Response 200
{ "data": [ { "commentID": "commentID", "userID": "userID", "time": "time", "stars": 123, "content": "content" }, { "commentID": "commentID", "userID": "userID", "time": "time", "stars": 123, "content": "content" } ] }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/star/comments/username=username"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/star/comments/username=username') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /star/username=:username
-
Type: GET
-
Response 200
{ "data": [ { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 }, { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 } ] }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/star/username=username"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/star/username=username') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /star/creation
-
Type: Post
-
Data
{ "userID": "username", "commentID": "commentID" }
-
Response 200
{ "count": 12 }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/star/creation"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"userID=test&commentID=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/star/creation', { userID: "username", commentID: 123 }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /star/deletion
-
Type: POST
-
Data
{ "userID": "username", "commentID": "commentID" }
-
Response 200
{ "count": 11 }
-
Response 400
{ "message": "err msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/star/deletion"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"userID=test&commentID=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/star/deletion', { userID: "username", commentID: 123 }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /user/login
-
Type: Post
-
Data
{ "username": "username", "password": "password" }
-
Response 200
{ "message": "success", "token": "token" }
-
Response 400
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/user/login"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"username=test&password=test"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/user/login', { username: "test", password: "test" }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /user/signup
-
Type: Post
-
Data
{ "username": "username", "password": "password", "telephone": "telephone" }
-
Response 200
{ "message": "success" }
-
Response 401
{ "message": "err msg" }
-
Response 500
{ "message": "Internal Server Error" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/user/signup"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"username=test&password=test"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/user/signup', { username: "test", password: "test" }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /user/verification
-
Type: Post
-
Data
{ "token": "token" }
-
Response 200
{ "username": "username" }
-
Response 403
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/user/verification"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"token=token"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/user/verification', { token: "token" }) .then((res) => { // code with res }); .catch((err) => { // code with err });
默认头像:MTc2MjI0NjU3MTIwMDE4MDIxMDU=.png
-
URL: /image/avatar/:filename
-
Type: GET
-
Response 200
Image file
-
Response 404
Not Found
-
Response 500
Internal Server Error
-
Objective-c
// Here shows the default avatar [cell.img sd_setImageWithURL:@"http://serverIP/image/avatar/MTc2MjI0NjU3MTIwMDE4MDIxMDU=.png" placeholderImage:[UIImage imageNamed:@"avatar.jpg"]];
-
URL: /user/info/:username
-
Type: GET
-
Response 200
{ "username": { "avatar": "url", "telephone": "tel" } }
-
Response 401
{ "message": "No match user" }
-
Response 500
{ "message": "Internal server error" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/user/info/0"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/user/info/0') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /user/avatar
-
Type: POST
-
Data
使用表单提交
{ "file": "Image file of avatar", "username": "username" }
-
Response 200
{ "avatar": "avatar file name string" }
-
Response 401
{ "message": "No match user" }
-
Response 500
{ "message": "Internal server error" }
-
Objective-c
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html", @"image/jpeg", @"image/png", @"application/octet-stream", @"text/json", nil]; manager.requestSerializer= [AFHTTPRequestSerializer serializer]; manager.responseSerializer= [AFHTTPResponseSerializer serializer]; [manager POST:@"http://serverIP/user/avatar" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { UIImage *image = [UIImage imageNamed:@"headImg"]; NSData *data = UIImageJPEGRepresentation(image, 1.0); //上传的参数(上传图片,以文件流的格式) [formData appendPartWithFileData:data name:@"file" fileName:@"headImg.jpg" mimeType:@"image/png"]; [formData appendPartWithFormData:[@"111" dataUsingEncoding:NSUTF8StringEncoding] name:@"username"]; } progress:^(NSProgress * _Nonnull uploadProgress) { } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSLog(@"上传成功"); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSLog(@"上传失败%@",error); }];
-
javascript
axios.post('http://serverIP/user/avatar', { username: "test", file: "file" }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /user/info
-
Type: POST
-
Data
{ "username": "username", "telephone": "tel" }
-
Response 200
{ "message": "success" }
-
Response 401
{ "message": "No match user" }
-
Response 500
{ "message": "Internal server error" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/user/info"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"username=test&telephone=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/user/info', { username: "test", telephone: "123" }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /user/password
-
Type: POST
-
Data
{ "username": "username", "oldPassword": "test", "newPassword": "test" }
-
Response 200
{ "message": "success" }
-
Response 401
{ "message": "No match user" }
-
Response 500
{ "message": "Internal server error" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/user/password"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"username=test&password=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/user/password', { username: "test", password: "test" }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /collection/username=:username
-
Type: GET
-
Response 200
{ "data": [ { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 }, { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 } ] }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/collection/username=username"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/collection/username=username') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /collection/creation
-
Type: Post
-
Data
{ "userID": "username", "newsID": "newsID" }
-
Response 200
{ "collection": 12 }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/collection/creation"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"userID=test&commentID=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/collection/creation', { userID: "username", commentID: 123 }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /collection/deletion
-
Type: POST
-
Data
{ "userID": "username", "newsID": "newsID" }
-
Response 200
{ "message": "success" }
-
Response 400
{ "message": "err msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/collection/deletion"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"userID=test&commentID=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/collection/deletion', { userID: "username", commentID: 123 }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /history/username=:username
-
Type: GET
-
Response 200
{ "data": [ { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 }, { "newsID": "newsID", "newsTitle": "newsTitle", "author": "author", "time": "time", "stars": 123, "comments": 123 } ] }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: (id)self delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/history/username=username"]; NSURLSessionDataTask *dataTask = [session dataTaskWithURL: url completionHandler: ^(NSData *data, NSURLResponse *response, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.get('http://serverIP/history/username=username') .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /history/creation
-
Type: Post
-
Data
{ "userID": "username", "newsID": "newsID" }
-
Response 200
{ "history": 12 }
-
Response 400
{ "message": "msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/history/creation"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"userID=test&commentID=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/history/creation', { userID: "username", commentID: 123 }) .then((res) => { // code with res }); .catch((err) => { // code with err });
-
URL: /history/deletion
-
Type: POST
-
Data
{ "userID": "username", "newsID": "newsID" }
-
Response 200
{ "message": "success" }
-
Response 400
{ "message": "err msg" }
-
Response 500
{ "message": "err msg" }
-
Objective-c
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration: config delegate: nil delegateQueue: nil]; NSURL *url = [NSURL URLWithString:@"http://serverIP/history/deletion"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *params = @"userID=test&commentID=123"; [request setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]]; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest: request completionHandler: ^(NSData *data, NSURLResponse *res, NSError *err) { if (nil == err) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData: data options: 0 error: nil]; // code with dict data } }]; [dataTask resume];
-
javascript
axios.post('http://serverIP/history/deletion', { userID: "username", commentID: 123 }) .then((res) => { // code with res }); .catch((err) => { // code with err });