1

i have this application that has a username & password . however i need to make it log in on a particular site and add a user and check profiles..i was told that i must use GET to add a user or query and parse the returning data's in json.

What are the particular steps that i will do?

i have tried some ways but it really didn't help at all

i searched on google but it seems that the one's that i found is not the one that i need.

thanks in advance :)

PS:im new to programming so please be gentle on me.(dived right in to ios dev.)

i have created the app and it goes like this

edited: i modified it a bit

- (IBAction)getDataPressed
{


    if([myRequest_ isExecuting])
    {
        return;
    }

    if(myRequest_ != nil)
    {

        [myRequest_ release];

    }   

    myRequest_ = [[ASIHTTPRequest alloc]initWithURL:[NSURL URLWithString:URL_PATH]];
    myRequest_.delegate = self;

    [myRequest_ startAsynchronous];


}

#pragma ASI Delegate methods
- (void)requestFinished:(ASIHTTPRequest *)request
{

    NSLog(@"Request finished successfully");
    NSLog(@"%@",[request responseString]);


    NSDictionary *responseDictionary = [[request responseString]JSONValue];
    NSDictionary *arrayElement = [responseDictionary objectForKey:@"user"];


    NSString *ID = [arrayElement valueForKeyPath:@"id"];
    NSLog(@"id: %d",ID);
    NSString *usr = [arrayElement valueForKeyPath:@"usr"];
    NSLog(@"usr: %@",usr);
    NSString *gd = [arrayElement valueForKeyPath:@"gd"];
    NSLog(@"gd: %@",gd);
    NSString *age = [arrayElement valueForKeyPath:@"ag"];
    NSLog(@"ag: %@",age);
    NSString *st = [arrayElement valueForKeyPath:@"st"];
    NSLog(@"st: %@",st);
    NSString *lf = [arrayElement valueForKeyPath:@"lf"];
    NSLog(@"lf: %@",lf);
    NSString *da = [arrayElement valueForKeyPath:@"da"];
    NSLog(@"da: %d",da);

    for(NSString *value in [arrayElement allValues]){
        NSLog(@"Found Value %@",value);

        label.text = value;
        [value release];
        [super release];

}
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSLog(@"Request failed");

}
-(void)dealloc {
    [super dealloc];
}


@end

still the same im getting the values but when i press the get data at the app. it closes. i need help pls. thanks i want the values to be posted on the label

NoobMe
  • 544
  • 2
  • 6
  • 26
  • does the site you are using provide any APIs? Usually POST requests are used for providing data to server. The site might be using oauth as well. – Nilesh Nov 29 '11 at 06:39
  • @Nilesh - yes they do have APIs – NoobMe Nov 29 '11 at 07:12
  • i use the NSZombieEnabled and it says that `2011-12-06 15:22:06.301 APITextProject[3705:207] *** -[APITextProjectViewController dealloc]: message sent to deallocated instance 0x5a516c0` – NoobMe Dec 06 '11 at 07:43

1 Answers1

0

You will have to check documentation provided for login API by them. Most probably might be using either POST request or OAuth authentication mechanism. Please try to provide detailed information in order to get proper help. :)

Nilesh
  • 5,955
  • 3
  • 24
  • 34
  • i dont know how to post codes.. uhmm i guess my only problem is about the json thing... i have the framework.. how can i insert it in my code? without errors – NoobMe Nov 29 '11 at 09:46
  • you dont need to provide complete code. You should provide snippet which is causing issue along with other details if possible. e.g. which website are you trying to log into if that's public site. If you think your json is wrong, then you can validate it with any online json validator. – Nilesh Nov 29 '11 at 10:09
  • can u give me a step by step guide on how to make this app? thanksss. – NoobMe Dec 02 '11 at 01:43
  • It seems that your webservice is returning the error : data query sent, incomplete! Check if you are sending all required parameters. Also try to form http request using some other tool and see if it works. You can do this using Poster addon for mozilla firefox or using cygwin curl utility. – Nilesh Dec 02 '11 at 09:18
  • its on php. the data query sent, incomplete! is alright... i just want to put the particular values on each id: can u pinpoint where i go wrong? thankss – NoobMe Dec 02 '11 at 09:44
  • You are receiving xml response while you are expecting JSON. You have to make changes to your server so that it sends JSON. If it returns json, your code will work. – Nilesh Dec 02 '11 at 13:44
  • it works the console show the values. but in the app when i press the get data it closes the app is it ok? – NoobMe Dec 05 '11 at 01:42
  • Check in Xcode. If app closes due to crash, you will get stack trace in IDE. App shouldn't crash ever. – Nilesh Dec 05 '11 at 06:21
  • when i press the get data button the application closes . then when i run the console the values that i was looking for are all there. what seems to be the problem? -.- – NoobMe Dec 05 '11 at 06:27
  • Connect to Xcode while running the application. See what you get in stack trace. It might help you locate the issue. You can configure Xcode to break when an exception is thrown. See: http://stackoverflow.com/questions/4961770/run-stop-on-objective-c-exception-in-xcode-4 – Nilesh Dec 05 '11 at 06:31
  • im getting "EXC_BAD_ACCESS" when i debug it – NoobMe Dec 05 '11 at 07:01
  • So you need to take a look at stack trace. Also check for which variable you are getting exception. Once you identify that, check if you are allocating/releasing it properly everywhere you have used it. You will have to do good amount of debugging for that :) – Nilesh Dec 05 '11 at 07:14