sending basic data between php functions on internet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Edwin Rozie

    #1

    sending basic data between php functions on internet

    Hey can U help me with the following?

    I would like to send basic data (like a set of integers & strings) from
    one php function to another php function.

    Sounds easy, However, the functions are located on a different computer.

    Or, said differently, I would like to use

    function oncomp1($intege r1, $string1, $string2)
    {
    // ...
    //string3 = function of string2

    //<-- call oncomp2($string 1,$string3,$int eger1);
    }

    where function oncomp1 is on computer 1, and oncomp2 is on computer 2.

    What to do?
    The strings can be to long (a few kb) to pass it simply in the URL.
    However WDDX is heavily overkill, because u need to compile php with
    --enable-wddx to use those functions. And WDDX do not cover communnication.

    Greetings,
    Edwin
  • Erwin Moller

    #2
    Re: sending basic data between php functions on internet

    Edwin Rozie wrote:

    Hi Edwin,
    [color=blue]
    > Hey can U help me with the following?
    >
    > I would like to send basic data (like a set of integers & strings) from
    > one php function to another php function.
    >
    > Sounds easy, However, the functions are located on a different computer.
    >
    > Or, said differently, I would like to use
    >
    > function oncomp1($intege r1, $string1, $string2)
    > {
    > // ...
    > //string3 = function of string2
    >
    > //<-- call oncomp2($string 1,$string3,$int eger1);
    > }
    >
    > where function oncomp1 is on computer 1, and oncomp2 is on computer 2.
    >
    > What to do?
    > The strings can be to long (a few kb) to pass it simply in the URL.
    > However WDDX is heavily overkill, because u need to compile php with
    > --enable-wddx to use those functions. And WDDX do not cover
    > communnication.[/color]

    Why not post it to a receiving script on server2?
    You can mimic a posting using CURL.
    www.php.net -> find CURL

    Good luck!

    Regards,
    Erwin Moller

    [color=blue]
    >
    > Greetings,
    > Edwin[/color]

    Comment

    • Micha³ Wo¼niak

      #3
      Re: sending basic data between php functions on internet

      > Why not post it to a receiving script on server2?[color=blue]
      > You can mimic a posting using CURL.
      > www.php.net -> find CURL[/color]

      I remember that I've found a PHP script that mimics posting. It's
      somewhere on www.php.net, in user comments under "POST" I believe.

      Cheers
      Mike

      Comment

      • Edwin Rozie

        #4
        Re: sending basic data between php functions on internet

        Hey all :)

        Michał Woźniak wrote:[color=blue]
        > I remember that I've found a PHP script that mimics posting. It's
        > somewhere on www.php.net, in user comments under "POST" I believe.
        >[/color]
        Do u remember more details about the script? I readed
        http://be.php.net/variables.external completly and didnt found it.
        Google couldnt help me neether, I tryed multiple searches.

        Thx for helping me out!

        Comment

        • Edwin Rozie

          #5
          Re: sending basic data between php functions on internet

          Michał Woźniak wrote:[color=blue][color=green]
          >>Why not post it to a receiving script on server2?
          >>You can mimic a posting using CURL.
          >>www.php.net -> find CURL[/color]
          >
          >
          > I remember that I've found a PHP script that mimics posting. It's
          > somewhere on www.php.net, in user comments under "POST" I believe.[/color]

          Ah, I found it :)

          For the people who want to use this in the future: It is in a reply of
          lukas on http://be2.php.net/manual/en/ref.curl.php.

          The script is:

          <?
          function HTTP_Post($URL, $data, $referrer="") {

          // parsing the given URL
          $URL_Info=parse _url($URL);

          // Building referrer
          if($referrer==" ") // if not given use this script as referrer
          $referrer=$_SER VER["SCRIPT_URI "];

          // making string from $data
          foreach($data as $key=>$value)
          $values[]="$key=".urlenc ode($value);
          $data_string=im plode("&",$valu es);

          // Find out which port is needed - if not given use standard (=80)
          if(!isset($URL_ Info["port"]))
          $URL_Info["port"]=80;

          // building POST-request:
          $request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
          $request.="Host : ".$URL_Info["host"]."\n";
          $request.="Refe rer: $referer\n";
          $request.="Cont ent-type: application/x-www-form-urlencoded\n";
          $request.="Cont ent-length: ".strlen($data_ string)."\n";
          $request.="Conn ection: close\n";
          $request.="\n";
          $request.=$data _string."\n";

          $fp = fsockopen($URL_ Info["host"],$URL_Info["port"]);
          fputs($fp, $request);
          while(!feof($fp )) {
          $result .= fgets($fp, 128);
          }
          fclose($fp);

          return $result;
          }

          $output1=HTTP_P ost("http://www.server1.com/script1.php",$_ POST);
          $output2=HTTP_P ost("http://www.server2.com/script2.php",$_ POST);
          ?>

          Comment

          Working...