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
Link to comment
Share on other sites

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()
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.