2012-01-16 65 views
3

我是一个新手,想弄清楚如何修改Foursquare iOS API“BZFoursquare”在这里找到:https://github.com/baztokyo/foursquare-ios-api 在他们的例子中,他们使用了一个全功能的ViewController。不过,我将拥有多个ViewController,因此希望拥有一个带有常用代码的AppController。我如何需要在ios5下执行此操作?Foursquare iOS API

感谢您的任何帮助。

回答

4

看到这个链接https://github.com/Constantine-Fry/Foursquare-API-v2/tree/master/Foursquare2-iOS。很容易整合iPhone的foursquare API。

嗨Marco, 将Foursquare2文件夹添加到您的项目中,并检查视图控制器中的身份验证。请参阅以下代码。它会帮助你。

- (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]; 

      } 
     }]; 

    } 
} 
+0

如何我需要集成这个API,如果我想使用故事板(SDK 4.1)? – Marco 2012-01-21 23:07:47

0

您还可以使用oAuth登录foursquare,因为它很容易实现。在oAuth 2.0中,您必须获取访问令牌并使用该访问令牌才能获取用户详细信息,如朋友和个人资料信息。 oAuth是2步验证方法,详细实现,因为你是新手,所以我找到了一个很好的教程,Login with Foursquare