+ Reply to Thread
Results 1 to 5 of 5

Thread: Unable to pull web page after server move.

  1. #1
    Stingray is offline x10Hosting Member Stingray is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    14

    Unable to pull web page after server move.

    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

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Unable to pull web page after server move.

    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?
    Nothing is always absolutely so.

  3. #3
    Stingray is offline x10Hosting Member Stingray is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    14

    Re: Unable to pull web page after server move.

    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.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Unable to pull web page after server move.

    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.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    Stingray is offline x10Hosting Member Stingray is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    14

    Re: Unable to pull web page after server move.

    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?

+ Reply to Thread

Similar Threads

  1. After the big server move...
    By vrufusx65v in forum Free Hosting
    Replies: 2
    Last Post: 04-22-2010, 02:26 PM
  2. unable to login to cpanel since move
    By afmmbob in forum Free Hosting
    Replies: 2
    Last Post: 04-05-2010, 01:04 PM
  3. Server Move
    By CWeb Creative in forum Off Topic
    Replies: 0
    Last Post: 01-30-2010, 08:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers