Add the DiffbotAPIClient folder to your project.
In Project Settings -> Build Phases -> Link Binary With Libraries, add libz.dylib
If your project is running ARC, you will need to add the "-fno-objc-arc" compiler flag to all "ASI*" files and Reachability.m. Do this in Project Settings -> Build Phases -> Compile Sources
Make general calls to the Diffbot API using this method:
+ (void)apiRequest:(DiffbotAPIRequestType)rType
UrlString:(NSString *)urlStr
OptionalArgs:(NSDictionary *)optArgs
Format:(DiffbotAPIFormatType)formatType
withCallback:(DiffbotAPIRequestCallback)callback;
You will need to set the developer token in DiffbotAPIClient.m
#define DIFFBOT_API_TOKEN @"sampletoken"
To add optional arguments to any api call, pass in an NSDictionary with the optional arguments.
NSString *articleURL = @"http://www.macrumors.com/2014/01/12/your-verse-ipad-ad";
NSDictionary *optionalArgs = @{
@"author": @"fields"
};
[DiffbotAPIClient apiRequest:DiffbotPageClassifierRequest UrlString:articleURL OptionalArgs:optionalArgs Format:DiffbotAPIFormatJSON withCallback:^(BOOL success, id result) {
if(success) {
NSLog(@"Call success: %@", result);
} else {
NSLog(@"Error: %@", result);
}
}];
NSString *articleURL = @"http://www.macrumors.com/2014/01/12/your-verse-ipad-ad";
NSDictionary *optionalArgs = @{
@"fields": @"author"
};
[DiffbotAPIClient apiRequest:DiffbotArticleRequest UrlString:articleURL OptionalArgs:optionalArgs Format:DiffbotAPIFormatJSON withCallback:^(BOOL success, id result) {
if(success) {
NSLog(@"Call success: %@", result);
} else {
NSLog(@"Error: %@", result);
}
}];
NSString *firstArticleURL = @"http://www.macrumors.com/2014/01/12/your-verse-ipad-ad";
NSString *secondArticleURL = @"http://www.huffingtonpost.com/2014/01/24/stephen-hawking-black-holes-event-horizons_n_4658220.html";
NSDictionary *dictOne = [DiffbotAPIClient dictForBatchRequest:DiffbotArticleRequest UrlString:firstArticleURL Method:@"GET" OptionalArgs:nil Format:DiffbotAPIFormatJSON];
NSDictionary *dictTwo = [DiffbotAPIClient dictForBatchRequest:DiffbotArticleRequest UrlString:secondArticleURL Method:@"GET" OptionalArgs:nil Format:DiffbotAPIFormatJSON];
[DiffbotAPIClient batchRequests:@[dictOne, dictTwo] withCallback:^(BOOL success, id result) {
NSLog(@"%@", result);
}];
-Initial commit by Dan Ha-