forked from sonofsky2010/TQT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TQTUserRequest.m
56 lines (47 loc) · 1.29 KB
/
TQTUserRequest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// TQTUserRequest.m
// TQT
//
// Created by lishunnian on 11-7-11.
// Copyright 2011年 __MyCompanyName__. All rights reserved.
//
#import "TQTUserRequest.h"
#import "TQTLoginRequest.h"
#import "QOauthKey.h"
#import "TQTApiUrl.h"
#import "QOauth.h"
#import "QWeiboRequest.h"
#import "NSURL+QAdditions.h"
#import "SBJsonParser.h"
#import "TQTWeiBo.h"
#import "TQTAppDelegate.h"
@implementation TQTUserRequest
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (TQTUser *)infoOfSelf
{
QOauthKey *oauthKey = [(TQTAppDelegate *)[[NSApplication sharedApplication] delegate] oauthKey];
QWeiboRequest *request = [[[QWeiboRequest alloc] init] autorelease];
NSString *response = [request syncRequestWithUrl:kUserInfoUrl httpMethod:@"GET" oauthKey:oauthKey parameters:nil files:nil];
SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
NSMutableDictionary *dict = [parser objectWithString:response];
if (dict && [[dict objectForKey:@"msg"] isEqualToString:@"ok"]) {
TQTUser *user = [[[TQTUser alloc] initWithDict:[dict objectForKey:@"data"]] autorelease];
return user;
}
return nil;
}
- (BOOL)updateInfo:(TQTUser *)userInfo
{
}
@end