Unable to pull web page after server move.

Stingray

New Member
Messages
14
Reaction score
0
Points
0
Before the big server move I was on Lotus. The following code was working fine. After the move, my account was lost and I had to re-signup for a hosting account which is fine. Now my new account is on cossacks and my code no longer works. it does'nt pull the content from the external web site.

I checked to make sure that allow_url_fopen is on and it seems to be.

Any idea???

Code:
function do_post_request($url, $data, $optional_headers = null) {
 $params = array('http' => array(
  'method' => 'POST',
  'content' => $data
 ));
 if ($optional_headers !== null) {
  $params['http']['header'] = $optional_headers;
 }
 $ctx = stream_context_create($params);
 $fp = @fopen($url, 'rb', false, $ctx);
 if (!$fp) {
  throw new Exception("Problem with $url, $php_errormsg");
 }
 $response = @stream_get_contents($fp);
 if ($response === false) {
  throw new Exception("Problem reading data from $url, $php_errormsg");
 }
 return $response;
}

Thank you
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
I tried running that function on Lotus and it worked calling a POST on another site.
You could try removing the @ warning suppression.

Does it throw one of your exceptions?

What sort of site are you posting to?
 

Stingray

New Member
Messages
14
Reaction score
0
Points
0
Tried to take out the @ nothing changes I get no warnings...
I am posting to a site where I supply my username and get my internet consumption page which I then parse and display the needed information.

here is how I call it:
Code:
$html = do_post_request($url, "lang=ENGLISH&compteInternet=$compteInternet&submit.x=35&submit.y=9");

echo "$html";

function do_post_request($url, $data, $optional_headers = null) {
	$params = array('http' => array(
		'method' => 'POST',
		'content' => $data
	));
	if ($optional_headers !== null) {
		$params['http']['header'] = $optional_headers;
	}
	$ctx = stream_context_create($params);
	$fp = fopen($url, 'rb', false, $ctx);
	if (!$fp) {
		throw new Exception("Problem with $url, $php_errormsg");
	}
	$response = stream_get_contents($fp);
	if ($response === false) {
		throw new Exception("Problem reading data from $url, $php_errormsg");
	}

	return $response;
}

And I get nothing in $html.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I can confirm your script works on Lotus, making a request to another page on Lotus (with minor alterations to support HTTP authentication). Make sure error reporting is set to the chattiest level (E_ALL). It's possible there's a warning that simply isn't displayed.
 

Stingray

New Member
Messages
14
Reaction score
0
Points
0
Is there a way I can put my code somewhere on Lotus to see if there is something different on cossack that would explain this?
 
Top