Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Correct format string for optional parameters

Fixes #34
If the request already contains optional parameters, the format string is slightly different for GET
requests as the access_token is no longer the only parameter.
  • Loading branch information...
commit 732b729f4227d876ba97c0ac8785136116af946b 1 parent f046f72
@philippec authored
Showing with 11 additions and 1 deletion.
  1. +10 −1 classes/PhFacebook.m
  2. +1 −0  private/PhFacebook_URLs.h
View
11 classes/PhFacebook.m
@@ -181,9 +181,18 @@ - (void) sendFacebookRequest: (NSDictionary*) allParams
BOOL postRequest = [[allParams objectForKey: @"postRequest"] boolValue];
if (postRequest)
+ {
str = [NSString stringWithFormat: kFBGraphApiPostURL, request];
+ }
else
- str = [NSString stringWithFormat: kFBGraphApiGetURL, request, _authToken.authenticationToken];
+ {
+ // Check if request already has optional parameters
+ NSString *formatStr = kFBGraphApiGetURL;
+ NSRange rng = [request rangeOfString:@"?"];
+ if (rng.length > 0)
+ formatStr = kFBGraphApiGetURLWithParams;
+ str = [NSString stringWithFormat: formatStr, request, _authToken.authenticationToken];
+ }
NSDictionary *params = [allParams objectForKey: @"params"];
View
1  private/PhFacebook_URLs.h
@@ -22,6 +22,7 @@
#define kFBErrorReason @"error_description="
#define kFBGraphApiGetURL @"https://graph.facebook.com/%@?access_token=%@"
+#define kFBGraphApiGetURLWithParams @"https://graph.facebook.com/%@&access_token=%@"
#define kFBGraphApiPostURL @"https://graph.facebook.com/%@"
Please sign in to comment.
Something went wrong with that request. Please try again.