diff --git a/BZFoursquare/BZFoursquare.h b/BZFoursquare/BZFoursquare.h index 668b0c6..3cde770 100755 --- a/BZFoursquare/BZFoursquare.h +++ b/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: @@ -31,6 +31,7 @@ @interface BZFoursquare : NSObject { NSString *clientID_; NSString *callbackURL_; + NSString *clientSecret_; NSString *version_; NSString *locale_; id sessionDelegate_; @@ -38,6 +39,7 @@ } @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 sessionDelegate; @@ -51,6 +53,7 @@ - (BOOL)isSessionValid; - (BZFoursquareRequest *)requestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id)delegate; +- (BZFoursquareRequest *)userlessRequestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id)delegate; @end diff --git a/BZFoursquare/BZFoursquare.m b/BZFoursquare/BZFoursquare.m index 40f2f98..e206e9b 100755 --- a/BZFoursquare/BZFoursquare.m +++ b/BZFoursquare/BZFoursquare.m @@ -45,6 +45,7 @@ @implementation BZFoursquare @synthesize clientID = clientID_; @synthesize callbackURL = callbackURL_; +@synthesize clientSecret = clientSecret_; @synthesize version = version_; @synthesize locale = locale_; @synthesize sessionDelegate = sessionDelegate_; @@ -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; @@ -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)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