2

私の他の2つの質問は、私の混乱と初心者のせいで、うまくいきませんでした(ここここ)。私の問題を明確にするために最後のバッシュがあります。

取引端末から過去の取引とシグナルを送信する必要があります。コードは MQL (C バリアント) であり、Wininet.dllを使用します。これを使用して、サーバーにデータを送信できます。

string sData, url;
sData = "abc123,etc,etc";
url = "webname.com/PHP/insert.php?testdata="+sData;
int request = InternetOpenUrl (open, url, NULL, 0, 0, 0);

サイトでinsert.phpスクリプトを使用して[testdata=] の後に続く文字列を読み取り、それをデータベースに挿入してさらに分析したいと考えています。この文字列は数千文字になる可能性があるため、URL の長さの制限が懸念されます。

人々は cURL と jQuery について言及しましたが、私が取引日誌から選択した日付によってはデータ文字列が非常に大きくなる可能性があるため、上記のコードを使用して POST 要求をシミュレートする方法がわかりません。

私はそれを正しい方法でやりたいと思っていますが、それは機械がフォームなしで互いに話しているだけなので、それが私を混乱させています.

この cURL の例を使用する場合、長い文字列を $data 変数に渡すにはどうすればよいですか?

前もって感謝します。

4

2 に答える 2

0

Success :)))))))))))))

I've managed to write to my database with tens of thousands of characters. I had problems connecting because I was using http:// in the domain name, but when i removed it the code worked and I was able to talk to my script.

MQL (C language)

string myData = "testdata=abc123etc...";
string header = "Content-Type: application/x-www-form-urlencoded";
int open = InternetOpen("HTTP_Client_Sample", 0, "", "", 0); 
int connect = InternetConnect(open, "website.com", 80, "", "", 3, 0, 1); 
int request = HttpOpenRequest(connect, "POST", "/PHP/insert.php", NULL, NULL, acceptTypes, 0, 1);
HttpSendRequest(request, header, StringLen(header), myData , StringLen(myData));

PHP

Notice how i'm now able to use $_POST method which has a limitation of:

suhosin.post.max_value_length 1000000

More than enough for my needs. Before, my PHP script used $_GET which can only read 512 chars.

include("connect.php"); //Connect to the database
$data = $_POST['testdata'];
$result = mysql_query("INSERT INTO test (testdata) VALUES ('$data')");
if ($result) echo $data;
else echo "Error ".$mysqli->error;
mysql_close(); 

Thank you for everyone's help, it's greatly appreciated :)

于 2014-01-08T15:41:36.547 に答える