Jump to content

Sockets help


anthonyiacono

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/99835-sockets-help/
Share on other sites

Ah. Lets look at line 3 then.

 

I don't really use these port thingys (sounds like i know)

 

But try using the full domain

$fp=pfsockopen("https://www.etology.com",80);

 

See if that works. And try http, im not sure if 80 works over http i think it may be a different port, then again im not sure.

 

Link to comment
https://forums.phpfreaks.com/topic/99835-sockets-help/#findComment-510819
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.