need help for coding string in mql4

 

I want to execute this command line by buiding script by shell32.dll in mt4

curl "-X POST -H "Authorization: Bearer +token+" -F "message=Hello " https://notify-api.line.me/api/notify";


extern string token =";askdjfeiwlll";

input string executablename ="curl";

input string commandline =" -X POST -H "Authorization: Bearer +token+" -F "message=Hello " https://notify-api.line.me/api/notify";

void OnStart()
  {
   StartProcess(ExecutableName,cammandline,);

  }



it show error 

'https' - semicolon expected

'https' - unexpected token probaly type is missing?

':' semicolon expected


How can I fill that string commandline parameter with  " \  :  with correctly

I try to use read manual but still confuse


Thank for help

Character Constants - Integer Types - Data Types - Language Basics - MQL4 Reference
Character Constants - Integer Types - Data Types - Language Basics - MQL4 Reference
  • docs.mql4.com
Character Constants - Integer Types - Data Types - Language Basics - MQL4 Reference
 
  1. invalid code
    input string commandline =" -X POST -H "Authorization: Bearer +token+" -F "message=Hello " https://notify-api.line.me/api/notify";
    corrected
    input string commandline =" -X POST -H \"Authorization: Bearer "+token+" -F \"message=Hello \" https://notify-api.line.me/api/notify";

  2. I'd recommend you create a batch file with what you want and then shell that.

  3. See:
              Syntax for calling AutoIt compiled Script (.exe) using ShellExecuteW in MT4 EA (Quest) - MQL4 programming forum (2015)
              run a *.bat from EA (Route206) - MQL4 programming forum (2015)
              Execute an exe-file from MQL (Steffen Siegert) - MQL4 programming forum (2016)

 

Why are you shelling out to CURL when you can simply use the WebRequest function for similar results?

2. Sending a request of any type specifying the custom set of headers for a more flexible interaction with various Web services.

int  WebRequest(
   const string      method,           // HTTP method
   const string      url,              // URL
   const string      headers,          // headers 
   int               timeout,          // timeout
   const char        &data[],          // the array of the HTTP message body
   char              &result[],        // an array containing server response data
   string            &result_headers   // headers of server response
   );

WebRequest - Common Functions - MQL4 Reference
WebRequest - Common Functions - MQL4 Reference
  • docs.mql4.com
WebRequest - Common Functions - MQL4 Reference
 
Fernando Carreiro #:

Why are you shelling out to CURL when you can simply use the WebRequest function for similar results?

2. Sending a request of any type specifying the custom set of headers for a more flexible interaction with various Web services.



Could you please edit  how to use webrequest I try but still have error.



extern string extoken = “[YourToken]” ;
void OnInit(){

LineNotify(extoken,”MQL4 Line Sent”);

}
void LineNotify(string token,string Massage){
string headers;
char post[], result[];

headers=”Authorization: Bearer “+token+”\r\n”;
headers+=”Content-Type: application/x-www-form-urlencoded\r\n”;

ArrayResize(post,StringToCharArray(“message=”+Massage,post,0,WHOLE_ARRAY,CP_UTF8)-1);

int res = WebRequest(“POST”, “https://notify-api.line.me/api/notify", headers, 10000, post, result, headers);

Print(“Status code: “ , res, “, error: “, GetLastError());
Print(“Server response: “, CharArrayToString(result));
}

 
Kiattichai Keeratiadisai #: Could you please example or link  how to use webrequest to send  message and picture code with line app with 3 input

I gave you a link to the documentation which has examples, so do your research. I'm not going to code it for you. If you need coding done for you, consider using the Freelance section.


 
Kiattichai Keeratiadisai #: Could you please edit  how to use webrequest I try but still have error.

Please edit your post (don't make a new one) and use "</>" icon or Alt+S to add your code properly to your post. It is difficult to read when you just copy/paste it as normal text.

Did you read the section in the documentation about providing permission to use the web address?

"Note: To use the WebRequest() function, add the addresses of the required servers in the list of allowed URLs in the "Expert Advisors" tab of the "Options" window. Server port is automatically selected on the basis of the specified protocol - 80 for "http://" and 443 for "https://"."


You have not provided any details of what errors you are getting. Show what is printed to the logs.