Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add support for userless access

  • Loading branch information...
commit e617ec650584c4c0c935ace16f78e3f353178c88 1 parent 23697d6
gooichi gooichi authored
5 BZFoursquare/BZFoursquare.h
... ... @@ -1,5 +1,5 @@
1 1 /*
2   - * Copyright (C) 2011 Ba-Z Communication Inc. All rights reserved.
  2 + * Copyright (C) 2011-2012 Ba-Z Communication Inc. All rights reserved.
3 3 *
4 4 * Redistribution and use in source and binary forms, with or without
5 5 * modification, are permitted provided that the following conditions are met:
@@ -31,6 +31,7 @@
31 31 @interface BZFoursquare : NSObject {
32 32 NSString *clientID_;
33 33 NSString *callbackURL_;
  34 + NSString *clientSecret_;
34 35 NSString *version_;
35 36 NSString *locale_;
36 37 id<BZFoursquareSessionDelegate> sessionDelegate_;
@@ -38,6 +39,7 @@
38 39 }
39 40 @property(nonatomic,copy,readonly) NSString *clientID;
40 41 @property(nonatomic,copy,readonly) NSString *callbackURL;
  42 +@property(nonatomic,copy) NSString *clientSecret; // for userless access
41 43 @property(nonatomic,copy) NSString *version; // YYYYMMDD
42 44 @property(nonatomic,copy) NSString *locale; // en (default), fr, de, it, etc.
43 45 @property(nonatomic,assign) id<BZFoursquareSessionDelegate> sessionDelegate;
@@ -51,6 +53,7 @@
51 53 - (BOOL)isSessionValid;
52 54
53 55 - (BZFoursquareRequest *)requestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id<BZFoursquareRequestDelegate>)delegate;
  56 +- (BZFoursquareRequest *)userlessRequestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id<BZFoursquareRequestDelegate>)delegate;
54 57
55 58 @end
56 59
17 BZFoursquare/BZFoursquare.m
@@ -45,6 +45,7 @@ @implementation BZFoursquare
45 45
46 46 @synthesize clientID = clientID_;
47 47 @synthesize callbackURL = callbackURL_;
  48 +@synthesize clientSecret = clientSecret_;
48 49 @synthesize version = version_;
49 50 @synthesize locale = locale_;
50 51 @synthesize sessionDelegate = sessionDelegate_;
@@ -67,6 +68,7 @@ - (id)initWithClientID:(NSString *)clientID callbackURL:(NSString *)callbackURL
67 68 - (void)dealloc {
68 69 self.clientID = nil;
69 70 self.callbackURL = nil;
  71 + self.clientSecret = nil;
70 72 self.version = nil;
71 73 self.locale = nil;
72 74 self.sessionDelegate = nil;
@@ -146,4 +148,19 @@ - (BZFoursquareRequest *)requestWithPath:(NSString *)path HTTPMethod:(NSString *
146 148 return [[[BZFoursquareRequest alloc] initWithPath:path HTTPMethod:HTTPMethod parameters:mDict delegate:delegate] autorelease];
147 149 }
148 150
  151 +- (BZFoursquareRequest *)userlessRequestWithPath:(NSString *)path HTTPMethod:(NSString *)HTTPMethod parameters:(NSDictionary *)parameters delegate:(id<BZFoursquareRequestDelegate>)delegate {
  152 + NSMutableDictionary *mDict = [NSMutableDictionary dictionaryWithDictionary:parameters];
  153 + [mDict setObject:clientID_ forKey:@"client_id"];
  154 + if (clientSecret_) {
  155 + [mDict setObject:clientSecret_ forKey:@"client_secret"];
  156 + }
  157 + if (version_) {
  158 + [mDict setObject:version_ forKey:@"v"];
  159 + }
  160 + if (locale_) {
  161 + [mDict setObject:locale_ forKey:@"locale"];
  162 + }
  163 + return [[[BZFoursquareRequest alloc] initWithPath:path HTTPMethod:HTTPMethod parameters:mDict delegate:delegate] autorelease];
  164 +}
  165 +
149 166 @end

0 comments on commit e617ec6

Please sign in to comment.
Something went wrong with that request. Please try again.