good morning everyone,
I'm trying to put a vba script in communication with a php on a web server.
the two scripts must be able to exchange data via HTTP requests
regarding VBA->PHP submission
it works, i put the values in the url and test the functionality on chrome,
from chrome it returns what I set in the ECHO command of the PHP file
but if the same request I execute it via SEND from VBA script and print the response
the comunication it's ok but
I get several lines of html code without much sense.
I can't figure out where the problem is.
place the two scripts below
Sub main()
interfacePath="http://angeli-smart.rf.gd/RequestManager.php"
vModello=GetVariableValue("MODELLO")
vMatricola=GetVariableValue("TELAIO")
vModello="RPE-V"
vMatricola="114"
machineVars= "modello=" & vModello & "&matricola=" & vMatricola
Set http=CreateObject("MSXML2.ServerXMLHTTP")
http.Open "POST", interfacePath, False
http.SetRequestHeader "Accept", "text/plain"
http.SetRequestHeader "Content-type", "application/x-www-form-urlencode"
http.SetRequestHeader "Cache-Control", "no-cache"
http.SetRequestHeader "Accept-Language", "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7"
http.SetRequestHeader "Upgrade-Insecure-Requests", "1"
http.Send (machineVar)
MsgBox http.ResponseText
If http.Status = 200 Then
SetVariableValue("OK_CONN",1)
MsgBox "online"
Else
SetVariableValue("OK_CONN",0)
MsgBox "off line"
End If
Set http=Nothing
End Sub
<?php
header("Content-Type: text/plain");
if ($_SERVER['REQUEST_METHOD'] === 'GET')
{
$modello = $_GET['modello'];
$matricola = $_GET['matricola'];
}
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$modello = $_POST['modello'];
$matricola = $_POST['matricola'];
}
echo "modello:".$modello." N.".$matricola;
?>