VB script on IIS to php on Apache

itdeptneci
itdeptneci used Ask the Experts™
on
Does anybody have experience with PHP and VB. I've had a request for this small bit of code to be run on an Apache server. (Attached file shows full asp file)

            DT700Location = Cstr(.QueryString("DT700Location"))
            'ServerPageToFetch = Cstr(.QueryString("ServerPageToFetch"))
            ServerPageToFetch = "http://192.168.1.115/EUSDK/default.xml"
            
            'Test with fixed value DT700Location = "http://192.168.1.63:5555/cgi/Push.cgi"
            
            strPOSTxml ="<DtermIPPush><PushItem type=""0"" URL=""" & ServerPageToFetch & """/></DtermIPPush>"

            dim xmlhttp
            set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
            xmlhttp.Open "POST", DT700Location, false
            xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
            xmlhttp.send strPOSTxml
Push04.asp.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
That's confusing.  What is supposed to run on IIS and what is supposed to run on Apache?  Note that POST and GET are HTTP protocols/commands and they work the same whether they come from ASP or PHP.

Author

Commented:
Sorry if there's any confusion.

That's my VB code that I have running happily on IIS.

I want the equivalent in PHP on Apache if it's possible?
Dave BaldwinFixer of Problems
Most Valuable Expert 2014
Commented:
In PHP on Apache, you will probably have to use 'curl'.  Apache/PHP does not have an exact duplicate of "MSXML2.ServerXMLHTTP".  'curl' is both more complicated and more powerful since HTTP isn't the only protocol it supports.  http://us2.php.net/manual/en/book.curl.php

Author

Commented:
Ok I'm being lazy not wanting to learn PHP. This really is a one off.

Is this easy in PHP? I just need an example for a PHP developer to understand my VB. It doesn't have to be bullet proof...

dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", "http://192.168.1.63:5555/cgi/Push.cgi", false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send "<DtermIPPush><PushItem type=""0"" URL=""http://192.168.1.115/EUSDK/default.xml""/></DtermIPPush>"
Top Expert 2004
Commented:
Here's a basic example:

http://php.net/manual/en/curl.examples-basic.php

You'll need to examine some of the functions available in curl to translate this properly.  Roughly speaking:

CreateObject = curl_init
Open and setRequestHeader = curl_setopt
send = curl_exec

Most of your difference will involve curl_setopt to configure the connection.  The success/failure, or result, if so configured, is made available as the result of curl_exec().  See the function pages for curl_init(), curl_setopt(), and curl_exec() for more info.  Some reading on curl_error(), curl_errno(), and curl_close() might be worth your while as well.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial