0

I have a php wordpress site that's running on IIS. I need to include, as part of that file, the response from a local ASP.NET page. PHP is reallly not my strongest language though.

The code I have is:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $_SERVER['DOCUMENT_ROOT']+'/GetDesigns.ashx?type=1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$localText = curl_exec($ch);
curl_close($ch);
echo $localText;
?>

Making a request to /GetDesigns.ashx?type=1 works from a browser and echos a string, but when the above code is used on the page, I get nothing.

Is there any way to do this or is it just me misusing PHP?

hakre
  • 193,403
  • 52
  • 435
  • 836
Echilon
  • 10,064
  • 33
  • 131
  • 217

1 Answers1

1
$_SERVER['DOCUMENT_ROOT']

will give you a file path.

Use

"http://".$_SERVER['SERVER_NAME']

or a hardcoded address instead.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088