Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
- (void)fillProfile
{
RevMobAds *revmob = [RevMobAds session];
[[FBRequest requestForGraphPath:@"me?fields=id,gender,age_range,birthday"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error == nil) {
NSString *gender = [result objectForKey:@"gender"];
if (gender != nil)
revmob.userGender = [gender isEqualToString:@"male"] ? RevMobUserGenderMale : RevMobUserGenderFemale;
NSNumber *minAge = [[result objectForKey:@"age_range"] objectForKey:@"min"];
if (minAge != nil)
revmob.userAgeRangeMin = [minAge integerValue];
NSNumber *maxAge = [[result objectForKey:@"age_range"] objectForKey:@"max"];
if (maxAge != nil)
revmob.userAgeRangeMax = [maxAge integerValue];
NSString *birhday = [result objectForKey:@"birthday"];
if (birhday != nil) {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"MM/dd/yyyy";
revmob.userBirthday = [formatter dateFromString:birhday];
#if ! __has_feature(objc_arc)
[formatter release];
#endif
}
NSString *userID = [result objectForKey:@"id"];
if (userID != nil) {
revmob.userPage = [NSString stringWithFormat:@"http://facebook.com/%@",userID];
}
} else {
NSLog(@"ERROR: %@",error);
}
}];
[[FBRequest requestForGraphPath:@"me/likes"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error == nil) {
NSArray *data = [result objectForKey:@"data"];
NSUInteger n = [result count];
__block NSMutableArray *interests = [NSMutableArray arrayWithCapacity:n];
[data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[interests addObject:[obj objectForKey:@"name"]];
}];
revmob.userInterests = interests;
} else {
NSLog(@"ERROR: %@",error);
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment