Reputation: 469
I'm using a CURL call to an API. The call gives back a HTML DOM tree that i echo inside an iframe. The problem is that the base url refers to my own site instead of the API's site. For example: <script type="text/javascript" src="/swf/swfobject.js"></script>
will refer to my website instead of the API's. I have looked at the CURL set options but i couldn't find what i'm looking for, could someone please help me? I tried using preg_replace which worked but i have a lot of diffrent inpredictable links. (and its way to dirty!)
Code of CURL call:
function CallAPI($method, $url, $data = false)
{
$curl = curl_init();
switch ($method)
{
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_PUT, 1);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// Optional Authentication:
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
//curl_setopt($curl, CURLOPT_USERPWD, "username:password");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
return curl_exec($curl);
}
$output = CallAPI($method, $url, $data);
echo $output;
HTML:
<iframe src="videorecorder.php" frameBorder="0" scrolling="no"></iframe>
Please help me!
Thanks
Upvotes: 0
Views: 1788