通过foursquare实现foursquare api登录。无法获取用户数据

时间:2015-08-13 07:14:59

标签: ios

通过foursquare实现foursquare api登录。如何在safari上登录后获取用户数据。我回到我的应用程序后获得访问令牌。我使用pod实现了适用于iOS的Foursquare API v2。

1 个答案:

答案 0 :(得分:0)

实施Four Square API密钥

在Appdelegate.m文件

中写下代码
 //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];

Write Below方法从FolurSquare Api

获取类别
 -(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);
         }];

    }

获取Vanue详细信息

    [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);
    }];