首页 > 代码库 > 微博API

微博API

 

Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/plain" UserInfo=0xa053d90 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0xa073260> { URL: https://api.weibo.com/oauth2/access_token } { status code: 200, headers {

    "Api-Server-IP" = "10.75.2.82";

    "Cache-Control" = "no-cache";

    Connection = "keep-alive";

    "Content-Length" = 117;

    "Content-Type" = "text/plain;charset=UTF-8";

    Date = "Thu, 15 Jan 2015 11:16:25 GMT";

    Expires = "Thu, 01 Jan 1970 00:00:00 GMT";

    Pragma = "No-cache";

    Server = "nginx/1.6.1";

} }, NSErrorFailingURLKey=https://api.weibo.com/oauth2/access_token, NSLocalizedDescription=Request failed: unacceptable content-type: text/plain, com.alamofire.serialization.response.error.data=http://www.mamicode.com/<7b226163 63657373 5f746f6b 656e223a 22322e30 30576355 34334434 415f336b 44613438 63663032 39313130 7747655f 7a222c22 72656d69 6e645f69 6e223a22 31353736 37393939 39222c22 65787069 7265735f 696e223a 31353736 37393939 392c2275 6964223a 22333037 39303737 31343022 7d>}

 

你可以用AFHTTPRequestOperationManager解决一切问题,遇到你的这个问题,你可以像这么写: 
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];//设置相应内容类型 
[manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { 
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
}];

如果是授权失败

回调网址与授权网址不应该是一致的

 

微博API