Skip to content

Instantly share code, notes, and snippets.

@BlairDuncan
Created May 21, 2010 03:56
Show Gist options
  • Save BlairDuncan/408438 to your computer and use it in GitHub Desktop.
Save BlairDuncan/408438 to your computer and use it in GitHub Desktop.
-(CPURLRequest)createFindRequestWithIdentifier:(BOOL)useIndentifier
{
var userID = [userID_TextField stringValue];
var userPW = [userPW_TextField stringValue];
var content = [[CPString alloc] initWithFormat:@"userID=%@&userPW=%@",
[userID urlencode],
[userPW urlencode]];
var contentLength = [[CPString alloc] initWithFormat:@"%d", [content length]];
var request = [[CPURLRequest alloc] initWithURL:@"http://torxserve01.bbdo.ca/sgl/devCappuccino/sgl/php/JSON_loginDev.php"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:content];
[request setValue:contentLength forHTTPHeaderField:@"Content-Length"];
[request setValue:"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
if (useIndentifier)
{
var serviceUser = userID,
servicePassword = userPW,
secret = [[CPString stringWithFormat:@"%@:%@", serviceUser, servicePassword] encodeBase64],
authorization = [CPString stringWithFormat:@"Basic %@", secret];
[request setValue:authorization forHTTPHeaderField:@"Authorization"];
}
return request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment