-
-
Save mattshapiro/7535843 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) searchForPlaces { | |
ACAccountStore *store = [[ACAccountStore alloc] init]; | |
ACAccountType *type = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; | |
NSArray *permissions = @[@"email"]; | |
NSDictionary *options = @{ ACFacebookAppIdKey : @"229934313842253", ACFacebookPermissionsKey : permissions, ACFacebookAudienceKey : ACFacebookAudienceOnlyMe }; | |
[store requestAccessToAccountsWithType:type options:options completion:^(BOOL granted, NSError *error) { | |
NSArray *accounts = [store accountsWithAccountType:type]; | |
ACAccount *account = [accounts firstObject]; | |
// Get the access token, could be used in other scenarios | |
//ACAccountCredential *fbCredential = [account credential]; | |
//NSString *accessToken = [fbCredential oauthToken]; | |
//NSLog(@"Facebook Access Token: %@", accessToken); | |
NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/search"]; | |
NSDictionary *parameters = @{ @"type" : @"place", @"center" : @"39.750655, -104.999127" }; | |
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:url parameters:parameters]; | |
[request setAccount:account]; | |
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { | |
NSError *jsonError; | |
NSDictionary *response = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonError]; | |
[self processResponseData: response]; | |
}]; | |
}]; | |
} | |
-(void) processResponseData: (NSDictionary *) responseData { | |
NSLog(@"%@", responseData); | |
NSArray * dataArray = [responseData objectForKey:@"data"]; | |
for(NSDictionary * location in dataArray) | |
{ | |
NSString * name = [location objectForKey:@"name"]; | |
NSDictionary * locData = [location objectForKey:@"location"]; | |
NSString * lat = [locData objectForKey:@"latitude"]; | |
NSString * lng = [locData objectForKey:@"longitude"]; | |
NSLog(@"loc name = %@ lat = %@ lng = %@", name, lat, lng); | |
} | |
NSArray *arrayOfNames = [responseData objectForKey:@"name"]; | |
NSLog(@"%@", arrayOfNames); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment