How to make PHP call a remote Script

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

    How to make PHP call a remote Script

    I have a remote script on a local network and I need to make Web App in
    PHP, call this remote script on a different machine. How do I do this?

    Many Thanks.

  • seaside

    #2
    Re: How to make PHP call a remote Script


    johnny schrieb:
    I have a remote script on a local network and I need to make Web App in
    PHP, call this remote script on a different machine. How do I do this?
    This way, for example:

    $viart_xml = fsockopen("www. server.com", 80, $errno, $errstr, 12);

    fputs($viart_xm l, "GET /aScript.xml HTTP/1.0\r\n");
    fputs($viart_xm l, "Host: www. server.com\r\n" );
    fputs($viart_xm l, "Referer: http://www. server.com\r\n" );
    fputs($viart_xm l, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0;
    Windows NT 5.1)\r\n\r\n");

    This may work too, but not using PHP 4.4.2
    [http://bugs.php.net/bug.php?id=36017]:

    $viart_xml = fopen("http://www.viart.com/viart_shop.xml" , "r");

    Comment

    • Erwin Moller

      #3
      Re: How to make PHP call a remote Script

      seaside wrote:
      >
      johnny schrieb:
      >
      >I have a remote script on a local network and I need to make Web App in
      >PHP, call this remote script on a different machine. How do I do this?
      >
      This way, for example:
      >
      $viart_xml = fsockopen("www. server.com", 80, $errno, $errstr, 12);
      >
      fputs($viart_xm l, "GET /aScript.xml HTTP/1.0\r\n");
      fputs($viart_xm l, "Host: www. server.com\r\n" );
      fputs($viart_xm l, "Referer: http://www. server.com\r\n" );
      fputs($viart_xm l, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0;
      Windows NT 5.1)\r\n\r\n");
      >
      This may work too, but not using PHP 4.4.2
      [http://bugs.php.net/bug.php?id=36017]:
      >
      $viart_xml = fopen("http://www.viart.com/viart_shop.xml" , "r");
      Much easier is using fopen("http://www.example.com/somescript.php" ) if the
      http-wrapper is enabled.

      If PHP has decided that filename specifies a registered protocol, and that
      protocol is registered as a network URL, PHP will check to make sure that
      allow_url_fopen is enabled. If it is switched off, PHP will emit a warning
      and the fopen call will fail.

      If you need to send information in a POST too, have a look at CURL.



      Regards,
      Erwin Moller

      Comment

      • hackajar@gmail.com

        #4
        Re: How to make PHP call a remote Script

        Above stuff is good, but just remember, when you call a remote script
        the web server it is running on WILL process the PHP in script, this is
        NOT the same as doing a "require_once() ", "Include()" call locally.

        Hackajar
        johnny wrote:
        I have a remote script on a local network and I need to make Web App in
        PHP, call this remote script on a different machine. How do I do this?
        >
        Many Thanks.

        Comment

        Working...