MT4で、WebReqestsを使いDiscordに画像を送信したいです。
以下のコードでファイルパスのみしか送信できません。
どのように記述すればよいでしょうか?お詳しい方ご教授お願いいたします。
c
1//+------------------------------------------------------------------+ 2//| mt4_discord.mq4 | 3//| Copyright 2022, MetaQuotes Software Corp. | 4//| https://www.mql5.com | 5//+------------------------------------------------------------------+ 6#property copyright "Copyright 2022, MetaQuotes Software Corp." 7#property link "https://www.mql5.com" 8#property version "1.00" 9#property strict 10 11input string WebhookURL = ""; 12//+------------------------------------------------------------------+ 13//| Expert initialization function | 14//+------------------------------------------------------------------+ 15int OnInit() 16 { 17//--- 18 MessageBox(AlertDiscord(WebhookURL, "hoge")); 19//--- 20 return(INIT_SUCCEEDED); 21 } 22//+------------------------------------------------------------------+ 23//| Expert deinitialization function | 24//+------------------------------------------------------------------+ 25void OnDeinit(const int reason) 26 { 27//--- 28 29 } 30//+------------------------------------------------------------------+ 31//| Expert tick function | 32//+------------------------------------------------------------------+ 33void OnTick() 34 { 35//--- 36 37 } 38//+------------------------------------------------------------------+ 39bool AlertDiscord(const string url, const string text) 40{ 41 string img = "AUDJPY-1.png"; 42 string path = TerminalInfoString(TERMINAL_DATA_PATH) + "\\MQL4\\Files\\" + img; 43 int status_code; 44 string headers; 45 char data[]; 46 char result[]; 47 48 if (IsTesting()) { 49 return(false); 50 } 51 52 StringToCharArray("content=" + path, data, 0, WHOLE_ARRAY, CP_UTF8); 53 54 status_code = WebRequest("POST", url, NULL, NULL, 5000, data, 0, result, headers); 55 56 if (status_code == -1) { 57 Print(GetLastError()); 58 return(false); 59 } 60 61 return(true); 62}
あなたの回答
tips
プレビュー