我有一流的朋友
#import "Friend.h"
#import "AFJSONRequestOperation.h"
#import "UIImageView+AFNetworking.h"
#import "AFHTTPClient.h"
@implementation Friend
-(id)init {
self = [super init];
return self;
}
-(id)initWithSecret:(NSString *)theSecret
userId:(NSString *)theUserId {
self = [super init];
if(self) {
secret = theSecret;
user_id = theUserId;
/// get friends
NSString *str = [NSString stringWithFormat:@"https://api.vk.com/method/friends.get?fields=first_name,last_name&uid=%@&access_token=%@", user_id, secret];
NSURL *url = [[NSURL alloc] initWithString:str];
NSURLRequest *friendRequest = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *friendOperation = [AFJSONRequestOperation JSONRequestOperationWithRequest:friendRequest success:^(NSURLRequest *friendRequest, NSHTTPURLResponse *response, id JSON) {
//converting to array
NSArray *ar = [JSON valueForKey:@"response"];
NSData …Run Code Online (Sandbox Code Playgroud)