【问题标题】:HTTP Post MQL4 to phpHTTP 将 MQL4 发布到 php
【发布时间】:2013-04-12 21:28:11
【问题描述】:

这是我尝试使用的一段代码,用于POST 一组 13 个参数值,从 MQL4 脚本到名为 upload.php 的外部 php 脚本

   string headers = "Content-Type: application/x-www-form-urlencoded";
   string data    = "{\"ohlcVectors\":{\"ticker\":\"dax\",\"barIntervalSeconds\":300,\"open\":[6844.2998046875," +
      "6847.7998046875]},\"className\":\"MAIndicator\",\"parameters\":{\"periods\":2}}";

string acceptTypes[1] = {"*/*"};

   int HttpOpen    = InternetOpenA(   "HTTP_Client_Sample", 1, NULL, NULL, 0 );
   int HttpConnect = InternetConnectA( HttpOpen, "127.0.0.1", 7777, NULL, NULL, 3, 0, 1 );
   int HttpRequest = HttpOpenRequestA( HttpConnect, "POST", "/tradesheet/upload.php", NULL, NULL, acceptTypes, 0, 1 );
                     HttpSendRequestA( HttpRequest, headers, StringLen( headers ), data, StringLen( data ) );

编译器不断抛出 data 是不兼容类型的错误。当我正在寻找 MQL4POST 参数发送到 php.但我需要那个字符串 data 来拥有我自己的参数值,但不知道如何以正确的格式放置它。

我尝试了很多搜索,但找不到任何有用的东西。

以下是我需要发送到upload.php的参数列表。有人可以帮我安排 HttpSendRequestA() 期望的格式吗?

string params[13][13];
params[0][0] = "x1";
params[0][1] = "GOD@GMAIL.com";

params[1][0] = "x2";
params[1][1] = 10000;

params[2][0] = "x3";
params[2][1] = 10000;

params[3][0] = "x4";
params[3][1] = "fxpro";

params[4][0] = "x5";
params[4][1] = "usd";

params[5][0] = "x6";
params[5][1] = 10000;

params[6][0] = "x7";
params[6][1] = 5000;

params[7][0] = "x8";
params[7][1] = 10;

params[8][0] = "x9";
params[8][1] = 10;

params[9][0] = "x10";
params[9][1] = "sdfskfms";

params[10][0] = "x11";
params[10][1] = 232;

params[11][0] = "x12";
params[11][1] = 230;

params[12][0] = "x13";
params[12][1] = "fxpro";

非常感谢

【问题讨论】:

    标签: mql4 metatrader4


    【解决方案1】:

    您使用 build 600 的可能性很大。 Build 600 支持 Unicode,不再支持 Ansi。

    因此这些是您必须使用的功能:

    InternetOpenW
    InternetConnectW
    HttpOpenRequestW
    HttpSendRequestW
    

    见下文:

    Mt4 b600 / ghttp.mqh and InternetOpenUrlA() problem

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多