greennerd / ideaegg-api Goto Github PK
View Code? Open in Web Editor NEWThe api doc of ideaegg.
Home Page: http://greennerd.github.io/ideaegg-api
License: Other
The api doc of ideaegg.
Home Page: http://greennerd.github.io/ideaegg-api
License: Other
api | v1 | v2 |
---|---|---|
点赞 | POST /ideas/:id/like |
PATCH/PUT /ideas/:id/vote |
取消点赞 | DELETE /ideas/:id/like |
DELETE /ideas/:id/vote |
用户信息更新 | PUT /users/:id |
PATCH/PUT /user |
收藏 | POST /ideas/:id/star |
PUT /ideas/:id/star |
我发布的 idea | GET /my/ideas |
GET /user/ideas/created |
用户自己点赞的 idea | GET /my/liked_ideas |
GET /user/ideas/voted |
用户自己收藏的 idea | GET /my/starred_ideas |
GET /user/ideas/starred |
给 idea 打标签 | PUT /ideas/:id/tag |
POST /ideas/:id/tags |
取消 idea 的标签 | PUT /ideas/:id/untag |
DELETE /ideas/:id/tags |
We call interface using AFNetworking 2.x, prefer to use JSON parameters.
path = [NSString stringWithFormat:@"%@?page=%@", path, _nextPage]; This line of code show the way to make commad is not good.
//[parameters setObject:@"ideaegg" forKey:@"username"]; This is good since parameter in JSON.
[manager.requestSerializer setValue:appDelegate.userKey forHTTPHeaderField:@"PRIVATE-TOKEN"]; Private TOKEN in the HttpHeader.
Sample code for load ideas:
- (void) onLoadMyIdeaList:(BOOL)isFirst{
NSString *baseURL = BASEURL;
NSString *path;
if(_loadType == 1){
path = [NSString stringWithFormat:@"%@/api/v1/my/ideas", baseURL];
}
if(_loadType == 2){
path = [NSString stringWithFormat:@"%@/api/v1/my/liked_ideas", baseURL];
}
if(_loadType == 3){
path = [NSString stringWithFormat:@"%@/api/v1/my/starred_ideas", baseURL];
}
if (!isFirst && ([_nextPage longValue] != 0)) {
path = [NSString stringWithFormat:@"%@?page=%@", path, _nextPage];
if ([self.dataSource count] >= [_totalRecords longValue]) {
[self reloadData];
}
}
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
//[parameters setObject:@"ideaegg" forKey:@"username"];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager.requestSerializer setValue:appDelegate.userKey forHTTPHeaderField:@"PRIVATE-TOKEN"];
[manager GET:path parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
//NSLog(@"JSON: %@", responseObject);
if ([responseObject isKindOfClass:[NSArray class]]) {
NSArray *responseArray = responseObject;
NSLog(@"Response NSArray! %ld records", (unsigned long)[responseArray count]);
[self onReadOneIdeaPackage:responseArray];
[self reloadData];
/* do something with responseArray */
} else if ([responseObject isKindOfClass:[NSDictionary class]]) {
//NSDictionary *responseDict = responseObject;
/* do something with responseDict */
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
[self reloadData];
}];
}
你可以也看看这个 gem:https://github.com/jch/html-pipeline
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.