Jump to content

response to a vba generated request


kain86

Recommended Posts

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;


?>

 

Link to comment
Share on other sites

<html> <body> <script type="text/javascript" src="/aes.js"
></script> <script>function toNumbers(d){var
e=;d.replace(/(..)/g,function(d){e.push(parseInt(d,
16));return e)function
toHex(for(var
d-,d=1= arguments.length&&arguments[0].constructor= -Array?argu
ments[0]:arguments,e="",t=0;f<d.length;f++)e+=(16> d[r]?"0":")+d[r].to
String(16);return e.toLowerCase()var
a-toNumbers("f655ba9d09a112d4968c63579db590b4],b=toNumbers('9
8344c2eee86c3994890592585b49180), c-toNumbers (e35f523ad410eba2f
03b836589d2564e"); document.cookie="__test="+toHex(slowAES.decrypt
(c,2,a,b))+; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/;
location.href="http://angeli-smart.rf.gd/RequestManager.php?modello
=RPE-V&matricola-114&i=1; </script> <noscript>This site requires
Javascript to work, please enable Javascript in your browser or use a
browser with Javascript support</noscript></body> </html>

 

Link to comment
Share on other sites

something i found!

i tried to check the request that was being sent from chrome and i copied the headers.

if i add the following parameter to the request in vba now it works.

but I don't know exactly why

.SetRequestHeader "cookie", "__test=25ded795b93a4589f6d616b3dba1cea3"

i grabbed the cookie var from the chrome headers 

someone know why??

 

 

 

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.