Results 1 to 5 of 5

Thread: Communication between two servers

  1. #1
    Join Date
    Feb 2007
    Posts
    21

    Question Communication between two servers

    Hi! I'd like to ask if anyone has any advice on how to accomplish a task I have. Basically, I have my server and it needs to request data from completely different web server. My php script needs to call a page on the other server and give it some parameters (simple post method would be great). The server on the other side is to return data to me which I will read. Format of the return data will either be plain text or xml.

    so to summarize my question:
    1) How to request a webpage from within php code.
    2) How to send parameters using post method with that request.

    I'd really appreciate it if anyone has any advice....

    Thanks!

  2. #2

    Default

    PHP's cURL module would probably fit your needs.

    http://www.php.net/curl
    Sign Up Now! Lots and lots of disk space, Tons of Transfer , Host unlimited domain names, a Free Domain Name, Legendary customer support
    Computers & Technology at Netdip

  3. #3
    Join Date
    Feb 2007
    Posts
    21

    Default

    thanks alot. curl did the trick and i used mcrypt for the encryption. if anyone's interested in checking out the very simple test code i have i can post it.

  4. #4

    Default

    I'd like to see the test code.
    Sign Up Now! Lots and lots of disk space, Tons of Transfer , Host unlimited domain names, a Free Domain Name, Legendary customer support
    Computers & Technology at Netdip

  5. #5
    Join Date
    Feb 2007
    Posts
    21

    Default Code

    Don't expect anything too fancy. So what I really needed was encrypted communication between two separate web servers. So here's my php file that returns the response. It's just a mime and mcrypt encoded message:

    PHP Code:
    $td mcrypt_module_open(MCRYPT_DES''MCRYPT_MODE_ECB'');
    mcrypt_generic_init($td"hello"12345678);

    $str base64_encode("here you go!");
    $enc mcrypt_generic ($td$str);

    echo 
    "10 ".base64_encode($enc); 
    The script the requests this data and decodes it is as follows:

    PHP Code:
    $td mcrypt_module_open(MCRYPT_DES''MCRYPT_MODE_ECB'');
    mcrypt_generic_init($td"hello"12345678);

    echo 
    "test!<br><br>";

    $curl_handle=curl_init();
    curl_setopt($curl_handle,CURLOPT_URL,'http://example.com/test/resp.php');
    curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
    $buffer curl_exec($curl_handle);
    curl_close($curl_handle);

    echo 
    $buffer."<br><br>";

    $a explode(" "$buffer);
    echo 
    "idx: ".$a[0]."<br>";
    echo 
    "content: ";
    echo 
    base64_decode(mdecrypt_generic ($tdbase64_decode($a[1])))."<br><br>"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
ankara escort