2010-10-22 137 views
0
i am developing one app which will login to vonage website and do some functions like call froward etc . For that purpose first i am trying to login to vonage website 

我没有登录到网站在iphone

https://secure.vonage.com/vonage-web/public/login.htm

2)使用livehttpheader附加实测值Vonage公司的登录URL这些步骤

1)来捕获呼出交请求数据,当我点击sigin

我发现的数据是

用户名=名为myUsername &密码=输入mypassword & redirectingURL =%2Fwebaccount%2Fdashboard%2Fchoose.htm & frontDoorLogin = & goToSelection =来电转驳& loginsubmit等号(=)+在

我得到了我的资料后,我开始在xcode编码,我不知道什么是最好的办法做到这一点,但我搜索了一段时间,然后我试着这样

-(IBAction) buttonpressed { 

    NSURL *url = [NSURL URLWithString:@"https://secure.vonage.com/vonage-web/public/login.htm"]; 

    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; 
    [request setValue:@"myuser" forKey:@"username"]; 
    [request setValue:@"mypass" forKey:@"password"]; 
    [request setValue:@"/webaccount/dashboard/choose.htm" forKey:@"redirectingURL"]; 
    [request setValue:@"" forKey:@"frontDoorLogin"]; 
    [request setValue:@"callforwarding" forKey:@"goToSelection"]; 
    [request setValue:@"Sign+In" forKey:@"loginsubmit"]; 
    [request setDelegate:self]; 
    [request startAsynchronous]; 



} 

- (void)requestFinished:(ASIFormDataRequest *)request 
{ 
    // Use when fetching text data 
    NSString *responseString = [request responseString]; 

    UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"Hmm" message:@"http works" delegate:self cancelButtonTitle:@"okay" otherButtonTitles:nil]; 

    [alert show]; 
    [alert release]; 
    NSLog(@"Output = %@",responseString); 

} 

- (void)requestFailed:(ASIFormDataRequest *)request 
{ 
    NSError *error = [request error]; 
    UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"fail" message:@"http fails" delegate:self cancelButtonTitle:@"okay" otherButtonTitles:nil]; 

    [alert show]; 
    [alert release]; 
} 

但是当我在模拟器中运行应用程序时,它崩溃了。

我在做数据发布的正确方法吗?有没有其他方法可以做到这一点?

任何一个可以帮助我在这个问题上

我使用asihttprequest库

在此先感谢

问候

编辑:我盲目的错误,我种SETVALUE代替setpostvalue,这将解决这个问题:)

+0

调试器中的错误是什么? – Jordan 2010-10-23 00:00:23

+0

我试着在调试器崩溃后[请求setValue:@“/ webaccount/dashboard/choose.htm”forKey:@“redirectingURL”]; 它似乎我不能使用这种方法发布,任何想法? – appleDE 2010-10-23 06:04:22

回答

2

看节题为Sending a form POST with ASIFormDataRequest

// using post value 
[request setPostValue:@"myuser" forKey:@"first_name"]; 

还我通常做我的警示与自动释放,不知道这是你的问题,但你可能想尝试的改变也

UIAlertView *alert= [[[UIAlertView alloc] initWithTitle:@"Hmm" message:@"http works" 
     delegate:self cancelButtonTitle:@"okay" otherButtonTitles:nil] autorelease]; 

    [alert show]; 

UIAlertView中代表代码

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex: 
                (NSInteger)buttonIndex { 
     // do your thing 
    } 
+0

感谢您的回复先生,我做了该教程中陈述的内容,并且删除了警报视图,但仍然出现同样的错误。我的主要问题是这种方式,我们用iPhone发布数据(抱歉,我是新的iPhone编码) – appleDE 2010-10-23 06:02:05

+0

我怀疑问题是你没有处理来自https网站的证书 – 2010-10-23 07:09:25

+0

你能告诉我如何处理https(ssl或xx)证书? – appleDE 2010-10-23 16:54:06