NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://mobile.twitter.com/session"]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
NSString *postString = [NSString stringWithFormat:@"authenticity_token=%@&username=%@&password=%@",@"9b670208fd22850ec791",@"urUsername",@"urPWD"];
[theRequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData to hold the received data.
// receivedData is an instance variable declared elsewhere.
receivedData = [[NSMutableData data] retain];
} else {
// Inform the user that the connection failed.
}
2 回答
我已经发现了以Objective-C方式解决这个问题的方法 . 我们可以使用NSURLConnection发布表单 .
码:
问我是否需要更多信息 .
如果您自己开发了网站,为什么不创建另一个入口点,您可以使用ssl安全地将用户名/密码传递给页面?如果SSL不是一个选项,您可以在应用程序中生成一个令牌并传递它 . 根本不需要传递用户名/密码 .