Hi,
I have a page that is making an XML POST-Request to an URL on a different server (e.g. "http://wwww.externalserver.com/login"). This server is sending plain HTML as response. The problem is, that the URL shown in the browser ist still on my local server, let's say "http://localhost/callExternal.php". The external URL is redirecting (302) to another page.
The returned HTML of this target page contains relative image paths. Because of the not matching URL these relative paths are not valid and therefore no images or stylesheets are loaded.
Is there a way to make CURL (or any other solution working in PHP4) changing the location so that these relative paths work (without parsing the HTML and changing the paths)?
This is the calling script "http://localhost/callExternal.php":
$data = '<?xml version="1.0" encoding="UTF-8"?><Some XML></Some XML>';
$res = curl_init('http://wwww.externalserver.com/login');
curl_setopt($res, CURLOPT_POST, 1);
curl_setopt($res, CURLOPT_HEADER, 0);
curl_setopt($res, CURLOPT_POSTFIELDS, $data);
curl_setopt($res, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($res, CURLOPT_HTTPHEADER, array("Content-Type: text/xml; charset=UTF-8"));
curl_exec($res);
curl_close($res);
And this is a snippet of the returned HTML with a link example:
<html>
<head>
<link rel="stylesheet" type="text/css" media="print" href="/css/screen.css" />
</head>
<body>test</body>
</html>
And the URL is still showing "http://localhost/callExternal.php", so the link to the Stylesheet obviously doesn't work.