I just test the face.com face recognition api and I have success with json requests:
NSString *url = @"http://api.face.com/faces/detect.json?api_key=myapi&api_secret=mysecret&urls=http://userserve-ak.last.fm/serve/_/47363849/Christina+Aguilera+HQ+PNG.png";
// Create new SBJSON parser object
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
// Perform request and get JSON back as a NSData object
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
// Get JSON as a NSString from NSData response
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
// parse the JSON response into an object
// Here we're using NSArray since we're parsing an array of JSON status objects
NSDictionary *obj = [parser objectWithString:json_string];
//
NSString *status = [obj objectForKey:@"status"];
//
NSLog(@"status: %@", status);
This works when I pass the api key, secret and the IMAGE ON THE WEB as GET params, like:
http://api.face.com/faces/detect.json?api_key=4b4b4c6d54c37&api_secret= &urls= http://farm3.static.flickr.com/2566/3896283279_0209be7a67.jpg
Now, I want to upload a raw image data from my app…but this is not so well documented on the site:
http://developers.face.com/docs/api/faces-detect/
There it says:
Code:
Optional [no name] The raw image data for the photo (when instead of url, an image is uploaded)
This is the problem:
How do I pass the raw data as POST along with the apikey and secret?
I know it must be as POST, but how?
Raw data = NSData, so all you need to do is append the imageData to the URL, as done below.