0

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:

Cocoa Client REST

zer02
  • 3,537
  • 4
  • 26
  • 63
  • 1
    The problem is with your response from localhost. See this answer [Send Nested JSON using AFNetworking][1]. [1]: http://stackoverflow.com/questions/16476428/send-nested-json-using-afnetworking – edzio27 Oct 27 '13 at 16:28
  • Mhh, I used the Cocoa Rest Client and tested the values. Everything works with my localhost function. So I am still unsure about that. I have a similar function, not using Facebook Inputs and it works. I am not sending any response back. – zer02 Oct 27 '13 at 17:16
  • OMG, I feel so stupid. Thanks for the advice. I checked operations.responseString. I typed name, instead of username in my NSdictionary. – zer02 Oct 27 '13 at 17:21

0 Answers0