« # »

Enviar datos por POST vía PHP

A modo de recordatorio!

PHP:
  1. function post($server, $uri, $port, $vars){
  2.     $page .= "POST ".$uri." HTTP/1.0\r\n";
  3.     $page .= "Host: ".$server.":".$port."\r\n";
  4.     $page .= "Content-Type: application/x-www-form-urlencoded\r\n";
  5.     $page .= "Content-Length: " . strlen($vars) . "\r\n\r\n";
  6.     $page .= $vars;
  7.     $protocol=($port==443)?'ssl':'http';
  8.    
  9.     $fp = fsockopen ($protocol.'://'.$server, $port, $errno, $errstr, 30);
  10.     if (!$fp){
  11.         die($errno .": ". $errstr);
  12.     }else{
  13.         fputs ($fp,$page);
  14.         $cont="";
  15.         while (!feof($fp)){
  16.             $cont.=fgets($fp);
  17.         }
  18.         fclose ($fp);
  19.         return $cont;
  20.     }
  21. }

Comentarios

Deja un comentario

(*: Datos necesarios para dejar un comentario)

Get Adobe Flash playerPlugin by wpburn.com wordpress themes