-
Notifications
You must be signed in to change notification settings - Fork 1
/
FBAPIGraph.m
38 lines (28 loc) · 1.03 KB
/
FBAPIGraph.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
//
// FBAPIGraph.m
// Crowd Guard
//
// Created by Alexander Ivanov on 11.04.17.
// Copyright © 2017 Alexander Ivanov. All rights reserved.
//
#import "FBAPIGraph.h"
#define URL_GRAPH @"https://graph.facebook.com/v2.8/"
@interface FBAPIGraph ()
@property (strong, nonatomic, readonly) NSURL *url;
@end
@implementation FBAPIGraph
__synthesize(NSURL *, url, [NSURL URLWithString:URL_GRAPH])
- (instancetype)initWithAccessToken:(NSString *)accessToken {
self = [self init];
if (self)
_accessToken = accessToken;
return self;
}
- (NSURLSessionDataTask *)startRequestWithGraphPath:(NSString *)graphPath parameters:(NSDictionary *)parameters completion:(void (^)(NSDictionary *))completion {
NSURL *url = [[self.url URLByAppendingPathComponent:graphPath] URLByAppendingQueryDictionary:[parameters dictionaryWithObject:self.accessToken forKey:@"access_token"]];
return [url sendRequestWithMethod:@"GET" header:Nil json:Nil completion:^(id json, NSURLResponse *response) {
if (completion)
completion(cls(NSDictionary, json));
}];
}
@end