Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
11-25-2010, 05:18 PM #1
- Join Date
- Nov 2010
- Thanked 0 Times in 0 Posts
extract url from xml response and redirect
I submit form data as an xml string - $strXML - using curl:
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('lead'=>$strXML));
$strResult = curl_exec($ch);
// close cURL resource, and free up system resources
The xml response is:
and I need to redirect the user to <redirect_url>.
I am trying the following:
$xml = new SimpleXMLElement($strResult);
header("Location:" . $xml->result->redirect_url);
but with no joy.
Could anyone suggest how I can achieve what I want?
11-25-2010, 06:30 PM #2
- Join Date
- Jul 2009
- South Yorkshire, England
- Thanked 304 Times in 303 Posts
This seems a bit of overkill:
$xml = new SimpleXMLElement($strResult); header("Location:" . $xml->result->redirect_url);
preg_match('~\<redirect_url\>([^\<]+)\<\/redirect_url\>~', $strResult, $uri); print_r($uri); header('Location: '.$uri);