我试图以这种方式向dropbox发布HTTP请求:
//NSString *urlString = [NSString stringWithFormat:@"https://api.dropbox.com/1/oauth/request_token"];
NSString *urlString = [NSString stringWithFormat:@"https://api.dropbox.com/1/delta"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
//set headers
[request addValue:@"OAuth oauth_version=\"1.0\"" forHTTPHeaderField: @"Authorization"];
//create the body
NSMutableData *postBody = [NSMutableData data];
//post
[request setHTTPBody:postBody];
//get response
NSHTTPURLResponse* urlResponse = nil;
NSError *error = [[NSError alloc] init];
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
NSString *result = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"Response Code: %d", [urlResponse statusCode]);
if ([urlResponse statusCode] >= 200 && [urlResponse statusCode] < 300) {
NSLog(@"Response: %@", result);
//here you get the response
}
响应应该是JSON字符串。
参数在这里:https://www.dropbox.com/developers/core/api#delta
它提供参数和版本,但我不知道如何设置它们。