Libraries: "Native" MQL HTTP Client

 

"Native" MQL HTTP Client:

This library implements two simple HTTP GET / POST function and does not require external dll(s).

Author: gino pilotino

 

Good job. Simple but useful.

 
thank you for commenting !
 

could you write a simle example, how to send strings via POST to a php script ?

I tried $text = $_POST["key1"];

and typed

#include <ghttp.mqh>

string params[2][2];

string response;

params[0][0] = "key1";

params[0][1] = "the_text_to_send";

and

string filenames[][];

HttpPOST("http://www.website.com", "/upload.php", params, filenames, response);

but no message has arrived the script ...

It would be very helpful ...

 
ulukai:

could you write a simle example, how to send strings via POST to a php script ?

I tried $text = $_POST["key1"];

and typed

#include <ghttp.mqh>

string params[2][2];

string response;

params[0][0] = "key1";

params[0][1] = "the_text_to_send";

and

string filenames[][];

HttpPOST("http://www.website.com", "/upload.php", params, filenames, response);

but no message has arrived the script ...

It would be very helpful ...


the first parameter is an hostname not an url, may you please try with the following ?


string params[1][2];

params[0][0] = "key1";
params[0][1] = "foobar";

string filenames[][];

string response;

HttpPOST("www.website.com", "/upload.php", params, filenames, response);
Comment(response);

 
gunzip:
ulukai:

could you write a simle example, how to send strings via POST to a php script ?

I tried $text = $_POST["key1"];

and typed

#include <ghttp.mqh>

string params[2][2];

string response;

params[0][0] = "key1";

params[0][1] = "the_text_to_send";

and

string filenames[][];

HttpPOST("http://www.website.com", "/upload.php", params, filenames, response);

but no message has arrived the script ...

It would be very helpful ...


the first parameter is an hostname not an url, may you please try with the following ?


string params[1][2];

params[0][0] = "key1";
params[0][1] = "foobar";

string filenames[][];

string response;

HttpPOST("www.website.com", "/upload.php", params, filenames, response);
Comment(response);


thank you for your fast answer, but this also did not help.

I tried the HttpGET function . It works, but POST not ...


I see that the functions UrlEncode and reserved_char are not beeing used ?


Is that correct. There is no reference to UrlEncode ...


I also tried active webserver and XAMPP with localhost ...

 
ulukai:

thank you for your fast answer, but this also did not help.

I tried the HttpGET function . It works, but POST not ...

I see that the functions UrlEncode and reserved_char are not beeing used ?

Is that correct. There is no reference to UrlEncode ...

I also tried active webserver and XAMPP with localhost ...


can you please post your exact code ? which version of windows are you running ?

urlencode is an auxiliary function you may use or not with your GET parameters,

put there for completeness.

 
i have win 7 64 bit, could that be the problem ?
 
ulukai:
i have win 7 64 bit, could that be the problem ?

yes it could be as i haven't tested this on a 64bit operating system.

to deal with this issue i have to investigate more mt4 internals (integers type)

or at least have a 64 bit machine to test this, i'll look for it.

 
really nice job!
 

I am getting an empty response from my http call using this library - any ideas what that might mean, at this stage i cant really understand the crux of the library itself ..

Thx :)

Reason: