I am having a problem and I am stuck. I want to send my information, which I fetched from Facebook to my server from iPhone.
Server Sided Function works, I tried with sample Key,Values and a Tool called "CocoaRestClient".
I am extracting data from:
NSDictionary<FBGraphUser> *user
This are my parameters:
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
user.name, @"name",
user.id, @"uid",
user.first_name, @"firstname",
user.last_name, @"lastname",
[user objectForKey:@"email"], @"email",
[FBSession activeSession].accessTokenData.accessToken, @"access_token",
nil];
My AFNetworking POST function:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:@"http://localhost:8888/iphonelogin" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
I am receiving following error in xCode:
Error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x8b950c0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
My Guess:
I guess that there has to be some problems with the NSDictionary values. I did NSLog and got following example values, the brackets seem to be different. Do I have to Typecast maybe? The email value gets saved on my server somehow... Thank you very much if you can help me.
Output xCode NSLog of parameters:
{"access_token" = 324234sdfdfdt345345345345435;
email = "myemail@mail.com";
firstname = John;
lastname = Doe;
name = "John Doe";
uid = 343434;}
PS: All attributes are stored as VARCHAR(255), except UID as bigint on my server.
If I use this Cocoa Client for testing, all entries are successfully posted into my tables: