473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.

Dec 22 '06 #1
3 3237

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_xml, "GET /aScript.xml HTTP/1.0\r\n");
fputs($viart_xml, "Host: www. server.com\r\n");
fputs($viart_xml, "Referer: http://www. server.com\r\n");
fputs($viart_xml, "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");

Dec 22 '06 #2
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_xml, "GET /aScript.xml HTTP/1.0\r\n");
fputs($viart_xml, "Host: www. server.com\r\n");
fputs($viart_xml, "Referer: http://www. server.com\r\n");
fputs($viart_xml, "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.
http://nl3.php.net/manual/en/function.fopen.php
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.
http://nl3.php.net/manual/en/ref.curl.php
Regards,
Erwin Moller
Dec 22 '06 #3
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.
Dec 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: steve | last post by:
Hi, I finally figured out the best way to synch local and remote script folders, containing many php script files. What I used to do before was try to ftp all the changed files, etc. which was...
4
by: Razzbar | last post by:
I need to be able to conditionally load a remote script, using the "<script src=..." syntax. Or some other way. I've seen people writing about using the document.write method, but it's not working...
2
by: Cheng Wei-Chao | last post by:
hi: i have a button, when i click it i want to store data to database and open a new window in general we use java script to open new window but how to call java script function after i...
3
by: Dexter | last post by:
Hello all, I need to build a chat using ASP.NET (VB), this chat is to the online communication with customers. I would like to know what is best. To use webservices or to use remote script? ...
6
by: ruca | last post by:
Hi, Can I call two script blocks for different languages in my ASP.NET code? I have a button than when clicked it must open a popup window to return some values for two other controls that I...
1
by: Alan Wang | last post by:
Hi all: I am just wondering if it's possible to call Unix script from VB.Net application. Thanks in advanced Alan
2
by: Sibou51 | last post by:
Hello everybody, do you know if it's possible to call a python script in html page?? I want call my script pyhton and I have a html with javascript but I don't know how, do you have an...
1
by: clteh9 | last post by:
There is no error or exception for the code below. It works fine with the calc.exe. But it fails when i call the script. For your information, strScript is the remote script and strFileName is the...
1
by: bbammes | last post by:
I'm writing a click tracking program which calls a remote PHP script when a user clicks a link. My javascript is: <script type="text/javascript"> //<! ); ?>&clientaddress=<?php echo urlencode(...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.