4

I'm using curl to post form data in xml string. The xml response is <redirect_url>www.xxxxx.com</redirect_url>. Could anyone help me to extract this url and redirect the user to it? Thanks.

Sorry been away... Thanks for the responses. The code is:

// create a new cURL resource

$ch = curl_init('http://www.zzz.com/');

// set r appropriate options

$strXML = "<lead>   <applicant>   <title>".$title."</title>   <fname>".$fname."</fname>   <lname>".$lname."</lname>   <email>".$email."</email>   <dob>".$dob."</dob>   </lead>";

echo $strXML;

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

echo $strResult;

curl_close($ch);

Example Response:

<result>
<posting_error>0</posting_error>
<valid_partner>1</valid_partner>
<redirect_url>www.xxx.com</redirect_url>
</result>
2
  • That doesn't look like XML to me. Could you show your code and the full response? Commented Nov 24, 2010 at 17:58
  • The website you put as example is actually a nudity website! Commented Feb 9, 2019 at 13:22

1 Answer 1

5

Use SimpleXML and header:

$xml = new SimpleXMLElement($xml_response);

header('Location: ' . $xml->redirect_url);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.