😽
MQL4,MQL5でLINE通知
string Line_token =""
void AlertLINE(string Message)
{
string headers;
char data[], result[];
int res, data_size, result_size;
// Correctly format headers
headers = "Authorization: Bearer " + Line_token + "\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n";
// Prepare data
string msg_data = "message=" + Message;
data_size = StringToCharArray(msg_data, data, 0, WHOLE_ARRAY, CP_UTF8);
ArrayResize(data, data_size); // Ensure the data array is correctly sized
// Prepare result array (optional, depending on your use case)
result_size = 1024; // Example size, adjust based on expected response size
ArrayResize(result, result_size);
// Send request
res = WebRequest("POST", "https://notify-api.line.me/api/notify", headers, 0, data, result,headers);
if(res == -1)
{
Print("Error in WebRequest. Error code = ", GetLastError());
MessageBox("Add the address 'https://notify-api.line.me' in the list of allowed URLs on tab 'Expert Advisors'", "Error", MB_ICONINFORMATION);
}
else
{
// Optionally, handle the response stored in 'result'
}
}
Discussion