Created
November 14, 2015 04:19
-
-
Save singer1026/17f7b91fb43ea3892736 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// ledongliDemo | |
// | |
// Created by Singer on 15/11/14. | |
// Copyright © 2015年 Singer. All rights reserved. | |
// | |
#import "ViewController.h" | |
#import "AFNetworking.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd]; | |
btn.backgroundColor = [UIColor orangeColor]; | |
btn.frame = CGRectMake(70, 80, 70, 30); | |
[self.view addSubview:btn]; | |
[btn addTarget:self action:@selector(submitSetp) forControlEvents:UIControlEventTouchUpInside]; | |
} | |
-(void)submitSetp{ | |
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"text/pain",@"application/json", nil]; | |
[manager.requestSerializer setValue:@"le dong li/5.4 (iPhone; iOS 9.1; Scale/2.00)" forHTTPHeaderField:@"User-Agent"]; | |
[manager.requestSerializer setValue:@"application/x-www-form-urlencoded; charset=UTF-8" forHTTPHeaderField:@"Content-Type"]; | |
[manager.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; | |
NSUInteger steps = 98800;//修改你需要的步数 | |
NSDate *date = [NSDate new]; | |
NSUInteger time = [date timeIntervalSince1970]; | |
NSArray *key = @[@{ | |
@"date": @(time), | |
@"calories": @0, | |
@"activeValue": @81,//随便改 | |
@"steps": @(steps), | |
@"pm2d5": @0, | |
@"duration": @0, | |
@"distance": @0, | |
@"lat":@0, | |
@"report": @"[]" | |
}]; | |
NSString *keyStr = [self DataTOjsonString:key]; | |
NSDictionary *dict = @{ | |
@"pc":@"xxxxx",//修改为你的pc值,需要抓包获取 | |
@"list": keyStr, | |
@"uid":@123456//修改为乐动力app里面的uid | |
}; | |
NSString *url = @"http://pl.api.ledongli.cn/xq/io.ashx?&action=profile&cmd=updatedaily&v=5.5%20ios&vc=551%20ios"; | |
[manager POST:url parameters:dict success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) { | |
NSLog(@"装逼成功"); | |
} failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) { | |
NSLog(@"装逼失败"); | |
NSLog(@"%@",error); | |
}]; | |
} | |
-(NSString*)DataTOjsonString:(id)object | |
{ | |
NSString *jsonString = nil; | |
NSError *error; | |
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object | |
options:NSJSONWritingPrettyPrinted // Pass 0 if you don't care about the readability of the generated string | |
error:&error]; | |
if (! jsonData) { | |
NSLog(@"Got an error: %@", error); | |
} else { | |
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; | |
} | |
return jsonString; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment