Jump to content


Photo

Converting ASP to PHP


  • Please log in to reply
2 replies to this topic

#1 siric

siric
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 11 April 2006 - 02:06 PM

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.



' 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



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


#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 April 2006 - 02:20 PM

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()

#3 siric

siric
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 11 April 2006 - 07:14 PM

[!--quoteo(post=363665:date=Apr 11 2006, 02:20 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 11 2006, 02:20 PM) View Post[/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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users