开发者

ASIFormDataRequest - iOS Application. How do I RETRIEVE a post variable

So I have this url that leads to a .php

So far I managed to retrieve every single thing except the actual XML that I want. the XML is stored in a variable called _xml.

if($this->outMethod=="" || $this->outMethod=="POST") //Default to POST
{
$_POST["_xml"] = $_xml; 
}

So I've already set the outMethod to POST but I don't understand how to retrieve the value within _xml.

- (void)grabURLInBackground
{
NSLog(@"grab url in background");
NSURL *url = [NSURL URLWithString:@"xxxxxxxxxxx"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"POST" forKey:@"outMethod"];
[request setPostValue:@"1" forKey:@"Entity_ID"];
[request setDelegate:self];
[request startAsynchronous];
NSLog(@"end of grabUrlInBackgroun");
}

don't worry the URL is right I just don't want to post it.

- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"A");
// Use when fetching text data
NSString *responseString = [request responseString];

// Use when fetching binary data
NSData *responseData = [request responseData];

if(responseString)
{
NSLog(@"responseData is not null");
}

NSLog(@"response string: %@", responseString);

//NSLog(@"%@", responseString);
}

What I get back is that the request is good, but there is no response in responseString. This is because my php does not want to print out any of the XML on screen in HTML but it stores the result in the variable _xml sent via post "$_POST["_xml"] = $_xml

My question is, how do I get back tha开发者_如何转开发t xml variable? Isn't there a method available within the ASIHTTPRequest library? I am using ASIFormDataRequest class not ASIHTTPRequest.


You have to print you variable in the php-file:

if($this->outMethod=="" || $this->outMethod=="POST") //Default to POST
{
    echo $_xml; 
}

A HTTPRequest (and the ASIFormDataRequest as well) isn't interested in any variables you declare in your *.php file. It only returns the string you actually print.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜