Search code examples
iosfoursquare

Foursquare iOS API


I'm trying to figure out how to modify the Foursquare iOS API "BZFoursquare" found here: https://github.com/baztokyo/foursquare-ios-api. In their example they use an all-in-one ViewController. However I'll be having multiple ViewControllers and therefore want to have one AppController with the commonly used code. How do I need to do this under ios5?


Solution

  • see this link https://github.com/Constantine-Fry/Foursquare-API-v2/tree/master/Foursquare2-iOS . It's easy to integrate the foursquare API for iPhone.

    Hi Marco, Add the Foursquare2 folder into your project and check the authentication in your view controller. See the following code. it will be help you.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        self.title = @"Foursquare";
        //check the authentication
        if ([Foursquare2 isNeedToAuthorize]) {
           //If needed show the webview 
            webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
            NSString *url = [NSString stringWithFormat:@"https://foursquare.com/oauth2/authenticate?display=touch&client_id=%@&response_type=code&redirect_uri=%@",OAUTH_KEY,REDIRECT_URL];
            NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
            [webView loadRequest:request];
            [webView setDelegate:self];
            [self.view addSubview:webView];
            [webView release];
            mTableView.hidden = YES;
        }else{
            //Show your view
            mTableView.hidden = NO;
            [Foursquare2 searchVenuesNearByLatitude:@"40.763" longitude:@"-73.990" accuracyLL:nil altitude:nil accuracyAlt:nil query:@"" limit:@"15" intent:@"" callback:^(BOOL success, id result){
                if (success) {
    
                    tableData = [[FoursquareParser parseSearchVenuesResultsDictionary:(NSDictionary*)result] retain];
                    [mTableView reloadData];
    
                }
            }];
    
        }
    }