Ich möchte mein geschriebene Visual Basic Skript auf php umschreiben.
Wie schaut der skript in php aus?
Variable:
StretchIP = "192.168.1.10"
StretchID = "qwert"
Wird diese Funktion aufgerufen, dann wird die komplette Webseite angezeigt.
GetData(StretchIP, StretchID, "/core/appliances")
Hier ist die Funktion:
Function GetData(ByVal StretchIP, ByVal StretchID, ByVal StretchPath)
Dim GetAdres = "http://" & StretchIP & StretchPath
Dim oHTTP As Object
Dim sPasswort As String
oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
oHTTP.Open("GET", GetAdres, False)
oHTTP.SetRequestHeader("Host", StretchIP)
sPasswort = "Basic " & Base64Encode("stretch:" & StretchID)
oHTTP.SetRequestHeader("Authorization", sPasswort)
oHTTP.Send()
GetResponse = oHTTP.ResponseText
GetStatus = oHTTP.Status
Return (oHTTP)
End Function
Wie schaut der skript in php aus?
Variable:
StretchIP = "192.168.1.10"
StretchID = "qwert"
Wird diese Funktion aufgerufen, dann wird die komplette Webseite angezeigt.
GetData(StretchIP, StretchID, "/core/appliances")
Hier ist die Funktion:
Function GetData(ByVal StretchIP, ByVal StretchID, ByVal StretchPath)
Dim GetAdres = "http://" & StretchIP & StretchPath
Dim oHTTP As Object
Dim sPasswort As String
oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
oHTTP.Open("GET", GetAdres, False)
oHTTP.SetRequestHeader("Host", StretchIP)
sPasswort = "Basic " & Base64Encode("stretch:" & StretchID)
oHTTP.SetRequestHeader("Authorization", sPasswort)
oHTTP.Send()
GetResponse = oHTTP.ResponseText
GetStatus = oHTTP.Status
Return (oHTTP)
End Function
Kommentar