Skip to content

Commit

Permalink
Add support for userless access
Browse files Browse the repository at this point in the history
  • Loading branch information
gooichi committed Oct 8, 2012
1 parent 23697d6 commit e617ec6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion BZFoursquare/BZFoursquare.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011 Ba-Z Communication Inc. All rights reserved.
* Copyright (C) 2011-2012 Ba-Z Communication Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -31,13 +31,15 @@
@interface BZFoursquare : NSObject {
NSString *clientID_;
NSString *callbackURL_;
NSString *clientSecret_;
NSString *version_;
NSString *locale_;
id<BZFoursquareSessionDelegate> sessionDelegate_;
NSString *accessToken_;
}
@property(nonatomic,copy,readonly) NSString *clientID;
@property(nonatomic,copy,readonly) NSString *callbackURL;
@property(nonatomic,copy) NSString *clientSecret; // for userless access
@property(nonatomic,copy) NSString *version; // YYYYMMDD
@property(nonatomic,copy) NSString *locale; // en (default), fr, de, it, etc.
@property(nonatomic,assign) id<BZFoursquareSessionDelegate> sessionDelegate;
Expand All @@ -51,6 +53,7 @@
- (BOOL)isSessionValid;

- (BZFoursquareRequest *)requestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id<BZFoursquareRequestDelegate>)delegate;
- (BZFoursquareRequest *)userlessRequestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id<BZFoursquareRequestDelegate>)delegate;

@end

Expand Down
17 changes: 17 additions & 0 deletions BZFoursquare/BZFoursquare.m
Expand Up @@ -45,6 +45,7 @@ @implementation BZFoursquare

@synthesize clientID = clientID_;
@synthesize callbackURL = callbackURL_;
@synthesize clientSecret = clientSecret_;
@synthesize version = version_;
@synthesize locale = locale_;
@synthesize sessionDelegate = sessionDelegate_;
Expand All @@ -67,6 +68,7 @@ - (id)initWithClientID:(NSString *)clientID callbackURL:(NSString *)callbackURL
- (void)dealloc {
self.clientID = nil;
self.callbackURL = nil;
self.clientSecret = nil;
self.version = nil;
self.locale = nil;
self.sessionDelegate = nil;
Expand Down Expand Up @@ -146,4 +148,19 @@ - (BZFoursquareRequest *)requestWithPath:(NSString *)path HTTPMethod:(NSString *
return [[[BZFoursquareRequest alloc] initWithPath:path HTTPMethod:HTTPMethod parameters:mDict delegate:delegate] autorelease];
}

- (BZFoursquareRequest *)userlessRequestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id<BZFoursquareRequestDelegate>)delegate {
NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithDictionary:parameters];
[mDict setObject:clientID_ forKey:@"client_id"];
if (clientSecret_) {
[mDict setObject:clientSecret_ forKey:@"client_secret"];
}
if (version_) {
[mDict setObject:version_ forKey:@"v"];
}
if (locale_) {
[mDict setObject:locale_ forKey:@"locale"];
}
return [[[BZFoursquareRequest alloc] initWithPath:path HTTPMethod:HTTPMethod parameters:mDict delegate:delegate] autorelease];
}

@end

0 comments on commit e617ec6

Please sign in to comment.