Jump to content

Converting ASP to PHP


siric

Recommended Posts

Hi,

I have a short script that I need to convert from ASP to PHP. It basically pushs headers and variables through a URL from a form.


[code]

' Assign values to variables
strURL = "http://192.168.254.1:7000/"
varRecipient = Request("frmPhone") & ":1:1"
varSubject = Request("frmSubject")
varMessage = Request("frmMessage")
varContentLength = Len(varSubject) + Len(varMessage)

Set oXmlHttp = Server.Createobject("Msxml2.ServerXMLHTTP")

oXmlHttp.open "POST", strURL, False

Call oXmlHttp.setRequestHeader("Host","Host")
Call oXmlHttp.setRequestHeader("X-Service","service")
Call oXmlHttp.setRequestHeader("X-Password","password")
Call oXmlHttp.setRequestHeader("X-Sender","sender")
Call oXmlHttp.setRequestHeader("X-Recipient",varRecipient)
Call oXmlHttp.setRequestHeader("Content-Length",varContentLength)

oXmlHttp.send(varSubject & varMessage)

If (oXmlHttp.status <> 200) Then
  ' If not successful display error response text and code
  strReturn = oXmlHttp.responseText
  Response.Write(strReturn & "<br>")
  Response.Write(oXmlHttp.status & "<br>")
  Response.Write(oXmlHttp.readyState & "<br><br>")
  Response.Write("Error!! <br><br>")
Else
  ' Else display sms sent
  Response.Write("<b>All Ok!</b> <br><br> Recipient(s): " & Request("frmPhone") & "<br> Subject: " & varSubject & "<br> Message: " & varMessage & "<br><br>")
End If

[/code]


So I am trying find the equivalent of

Server.Createobject,
oXmlHttp.setRequestHeader,
oXmlHttp.send,
Response.Write

It is possible? My research is pointing me in the direction of AJAX. Is that the only option?

Thanks

Steve
Firtly, the Msxml2.ServerXMLHTTP object is not a native asp object, but an extension. It looks like most of this functionality would be available in php's [a href=\"http://php.net/curl\" target=\"_blank\"]curl[/a] extension though.

Server.Createobject = curl_init()
oXmlHttp.setRequestHeader = curl_setopt()
oXmlHttp.send = curl_exec()
Response.Write = echo()
[!--quoteo(post=363665:date=Apr 11 2006, 02:20 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 11 2006, 02:20 PM) [snapback]363665[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Firtly, the Msxml2.ServerXMLHTTP object is not a native asp object, but an extension. It looks like most of this functionality would be available in php's [a href=\"http://php.net/curl\" target=\"_blank\"]curl[/a] extension though.

Server.Createobject = curl_init()
oXmlHttp.setRequestHeader = curl_setopt()
oXmlHttp.send = curl_exec()
Response.Write = echo()
[/quote]


Thanks for the info.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.