Hey, I am trying to write a script to retrieve values from a webpage's source code, but in order to get there I need to fake a POST with the correct data to authenticate myself, this is what I have right now:

<?php
  // First Etology
  $fp=pfsockopen("https://etology.com",80);
  if($fp)
  {
    echo("Etology connection open...<br />\n");

// Login by faking the process.
$data="loginUserName=SOMEUSERNAME&loginPassword=SOMEPASSWORD\r\n";
$data=urlencode($data);
$header = 'POST /user-signup.php HTTP/1.0\r\n';
$header.= 'HOST: etology.com\r\n';
$header .= 'Content-Type: application/x-www-form-urlencoded\r\n';
$header .= 'Content-Length: ' . strlen($data) . '\r\nUser-Agent: Mozilla\r\n\r\n';
echo("Sending data...<br />\n");
fputs($fp,$header);
echo("Done sending.<br />\n");

// Read data
$header = 'GET /selling-statistic-payment.php HTTP/1.0\r\n';
$header.= 'HOST: etology.com\r\n';
$header.= 'User-Agent: Mozilla\r\n\r\n';
fputs($fp,$header);
while(!feof($fp)) 
{
  $info=fgets($fp);
}
echo($info);

// Close connection.
fclose($fp);
  }
?>

But when I do this I get:

Warning: pfsockopen() [function.pfsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/aiacono/public_html/boltradio/get_ads.php on line 3

Warning: pfsockopen() [function.pfsockopen]: unable to connect to https://etology.com:80 in /home/aiacono/public_html/boltradio/get_ads.php on line 3

Any ideas?

    Try using [man]cURL[/man] functions with the appropriate SSL options? (I'm assuming that the https is the problem here.)

      Write a Reply...