我正在一个名为 kodingen 的云平台上编程。我即将举行一场投资比赛,我正在制定一个方程式/算法来自动为我交易。我要做到这一点的方式(记住交易网站在 php/html 中)是通过使用 PHP 的 curl 扩展将数据发布到网站。我希望该功能每 10 分钟更新一次,并将购买/出售命令发布到网站。不包括更新功能。为什么这不起作用,它是否与会话和 cookie 无法存储在云计算机上有关。
function post_to_url($url, $data) {
$fields = '';
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($post);
curl_close($post);
}
$data1 = array(
"ifs-note" => "",
"submitted" => 1,
"confirmed" => 0,
"ifs-quantity" => 100,
"ticker" => "ADM:LN"
);
$data = array(
"loginsubmitted" => 1,
"team-name" => "xxxxxxxxx",
"team-password" => "xxxxxxxxxx"
);
$data2 = array(
"ifs-note" => "",
"submitted" => 0,
"confirmed" => 1,
"dis_ifs-quantity" => 100,
"ticker" => "ADM:LN",
"ifs-cost" => "1139.595"
);
post_to_url("https://www.studentinvestor.org/secure/login.php", $data);
post_to_url("http://www.studentinvestor.org/stock-buy.php", $data1);
post_to_url("http://www.studentinvestor.org/stock-buy.php", $data2);
echo $_SERVER['SERVER_NAME'];
var_dump($_SESSION);
我试过在数字周围加引号和不加引号。有没有更好的解决方案来完成整个过程,例如在远程计算机上使用 python 脚本进行 ssh?谢谢大家