Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix app requests in Hackbook sample.

Summary: Fix Hackbook sample's app requests to properly parse response on success. Also some minor clean up and simplification.

Test Plan:
Ran sample in simulator, verified app requests show success status.

Revert Plan:

Reviewers: jacl, caabernathy

Reviewed By: jacl

Differential Revision: https://phabricator.fb.com/D585439

Task ID: 1768482
  • Loading branch information...
commit 8868dcb77b9acd4938f3588a9a15eaa17980622b 1 parent 1ee2ea3
@chrisp-fb chrisp-fb authored
View
24 samples/Hackbook/Hackbook/APICallsViewController.m
@@ -262,11 +262,9 @@ - (NSDictionary *)parseURLParams:(NSString *)query {
NSMutableDictionary *params = [[[NSMutableDictionary alloc] init] autorelease];
for (NSString *pair in pairs) {
NSArray *kv = [pair componentsSeparatedByString:@"="];
- NSString *val =
- [[kv objectAtIndex:1]
- stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- [params setObject:val forKey:[kv objectAtIndex:0]];
+ [params setObject:[[kv objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
+ forKey:[[kv objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
return params;
}
@@ -1194,18 +1192,20 @@ - (void)dialogCompleteWithUrl:(NSURL *)url {
case kDialogRequestsSendToSelect:
case kDialogRequestsSendToTarget:
{
- // Successful requests return one or more request_ids.
- // Get any request IDs, will be in the URL in the form
- // request_ids[0]=1001316103543&request_ids[1]=10100303657380180
- NSMutableArray *requestIDs = [[[NSMutableArray alloc] init] autorelease];
+ // Successful requests return the id of the request
+ // and ids of recipients.
+ NSMutableArray *recipientIDs = [[[NSMutableArray alloc] init] autorelease];
for (NSString *paramKey in params) {
- if ([paramKey hasPrefix:@"request_ids"]) {
- [requestIDs addObject:[params objectForKey:paramKey]];
+ if ([paramKey hasPrefix:@"to["]) {
+ [recipientIDs addObject:[params objectForKey:paramKey]];
}
}
- if ([requestIDs count] > 0) {
+ if ([params objectForKey:@"request"]){
+ NSLog(@"Request ID: %@", [params objectForKey:@"request"]);
+ }
+ if ([recipientIDs count] > 0) {
[self showMessage:@"Sent request successfully."];
- NSLog(@"Request ID(s): %@", requestIDs);
+ NSLog(@"Recipient ID(s): %@", recipientIDs);
}
break;
}
View
1  samples/Hackbook/Hackbook/RootViewController.m
@@ -220,7 +220,6 @@ - (void)loadView {
menuTableView.dataSource = self;
menuTableView.delegate = self;
menuTableView.hidden = YES;
- //[self.view addSubview:menuTableView];
// Table header
headerView = [[UIView alloc]
Please sign in to comment.
Something went wrong with that request. Please try again.