通过foursquare实现foursquare api登录。如何在safari上登录后获取用户数据。我回到我的应用程序后获得访问令牌。我使用pod实现了适用于iOS的Foursquare API v2。
答案 0 :(得分:0)
实施Four Square API密钥
//Integarate FourSquare
NSString *yourClientId = @"WSTKVX3HJDWNZHEGZT3PLJQZNP5DUBDIEEUJZC2WVTOXRVWN";
NSString *yourClientSecret = @"R1BR2I5DCSLYNDO1BIGIFNJFMO5SOLOL12WNAPO3FZVIF0Z2";
NSString *yourCallbackURl = @"http://www.TestApp.com/Tapp"; //yourapp://foursquare
[UXRFourSquareNetworkingEngine registerFourSquareEngineWithClientId:yourClientId andSecret:yourClientSecret andCallBackURL:yourCallbackURl];
self.fourSquareEngine = [UXRFourSquareNetworkingEngine sharedInstance];
-(void)fetchCategoryDataFromFourSquare
{
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = @"";
[ApplicationDelegate.fourSquareEngine getCategoriesWithCompletionBlock:^(NSDictionary *dictCategoryInfo)
{
NSArray *arr = [dictCategoryInfo objectForKey:@"categories"];
mutArrCategoryData = [arr mutableCopy];
[MBProgressHUD hideHUDForView:self.view animated:YES];
[tblView reloadData];
} failureBlock:^(NSError *error)
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"%@",error);
}];
}
[ApplicationDelegate.fourSquareEngine getVeuneDetail:_strVenueID withCompletionBlock:^(NSDictionary *dictNearbyData)
{
[self setDetailsWithInfo:[dictNearbyData objectForKey:@"venue"]];
[MBProgressHUD hideHUDForView:self.view animated:YES];
} failureBlock:^(NSError *error)
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
// NSLog(@"%@",error);
}];
NSString *url = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/photo?photoreference=%@&key=%@&sensor=false&maxwidth=320", photoRef, kGOOGLE_API_KEY];
[ApplicationDelegate.fourSquareEngine getNearLocation:loc withCompletionBlock:^(NSDictionary *dictNearbyData)
{
NSArray *arr = [dictNearbyData objectForKey:@"venues"];
if([arr count]!=0)
{
NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"location.distance" ascending:YES];
NSMutableArray *tempArray = [arr mutableCopy];
[tempArray sortUsingDescriptors:@[sort]];
for(int i=0;i<[tempArray count];i++)
{
if([[[tempArray objectAtIndex:i] valueForKeyPath:@"location.distance"] intValue] < 804.5)
{
[mutArrNearByLocationData addObject:[tempArray objectAtIndex:i]];
}
}
// ----- Add predicate for check whose distance is less than 0.5 miles (804.5 meters)
// NSPredicate *DistancePredicate = [NSPredicate predicateWithFormat:@"distance <= 804.5"];
// NSArray *LoyaltyfilteredAry = [mutArrNearByLocationData filteredArrayUsingPredicate:DistancePredicate];
[MBProgressHUD hideHUDForView:self.view animated:YES];
[tblView reloadData];
}
else
{
showAlertView(@"No locations within 0.5 miles");
}
//[self showNearByPlaceOnMap:mutArrNearByLocationData];
} failureBlock:^(NSError *error)
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"%@",error);
}];