Avatar of nbcit
nbcit
 asked on

cURL to view remote page

I have a fairly simple cURL call that should display a frameset on a remote server. It's returning the frameset but trying to serve it as if it was local. As the frame source is relative and not absolute, I get 'Page cannot be displayed' errors. I have no access to the remote server (it's an API).

I just want the remote server to display the frameset.

I've tried
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
and
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
and
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);



--
Example additional post vars are below

Array
(
    [aid] => 123123
    [assign] => TestAssign
    [ctl] => Test101
    [diagnostic] => 0
    [encrypt] => 0
    [fcmd] => 2
    [fid] => 7
    [gmtime] => 20080410164
    [oid] => 64484479
    [tem] => instructoremail@domain.com
    [uem] => useremail@gmail.com
    [ufn] => bob
    [uln] => bobble
    [upw] => bob123
    [utp] => 1
    [md5] => 39ccc119fee92ae9042938f29ef30975
)
$ch = curl_init('https://www.turnitin.com/api.asp');
	curl_setopt($ch, CURLOPT_POSTFIELDS, $apivalues );
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	//curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
	curl_setopt($ch, CURLOPT_HEADER, 1);//retrieve headers
 
	$data = curl_exec($ch);
	curl_close($ch);

Open in new window

PHP

Avatar of undefined
Last Comment
nbcit

8/22/2022 - Mon
hielo

What are you doing with the content you fetch?
Are you serving the whole page from your site? => incorporate a <base href="remoteurl"> at the top of the page
 as a whole or are you intergrating within some page on your site?=>search and replace href="" so that it starts with the url of the remote site
nbcit

ASKER
With all other calls to the API, XML is returned and parsed but in this case the remote site is trying to display a frameset with local paths.

nbcit

ASKER
I'd be happy to serve their page in a new window and be done.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
hielo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
nbcit

ASKER
<base href='http://www.somesite.com/somefolder/test.php'>

should go in the <head> tags but they are serving the entire HTML. It would be correct HTML but I think it would still work?

I've managed to workaround the problem though by not posting this particular call and using GET instead. Not ideal but it works.