help.h
//通过这个方法可以获取倒授权登陆的完整的拼接好的接口
+(NSURL*)getAuthorizeURL;
help.m
+(NSURL *)getAuthorizeURL
{
// 一个字典 Key value
// 基本URL
//SINA_APP_KEY 为URL公共部分
NSDictionary *params = @{@"client_id":SINA_APP_KEY,@"redirect_uri":redirect_uri,@"display":@"mobile",@
"response_type":@"token"};
NSURL *authorizeUrl = [help connectWithAuthorizeUrl:SINA_AUTHORIZE_SEVER andParams:params];
return authorizeUrl;
}
+(NSURL *)connectWithAuthorizeUrl:(NSString *)baseUrl andParams:(NSDictionary *)params
{
if (params == nil) {
return [NSURL URLWithString:baseUrl];
}else{
NSMutableArray *keyValues = [[NSMutableArray alloc]init];
for (NSString *key in params.keyEnumerator) {
NSString *keyAndValue = [NSString stringWithFormat:@"%@=%@",key,params[key]];
[keyValues addObject:keyAndValue];
NSLog(@"%@",keyAndValue);
}
NSLog(@"%@",keyValues);
path = [keyValues componentsJoinedByString:@"&"];
NSLog(@"%@",path);
path = [NSString stringWithFormat:@"%@?%@",baseUrl,path];
}
return [NSURL URLWithString:path];
}