我想在spray中获取String和integer之类的参数,例如:
<?php
$username = "";
$password = "";
$url = "https://wordpress.com/wp-login.php";
$cookie = "cookie.txt";
$postdata = "log=".$username."&pwd=".$password."&rememberme=forever&wp-submit=Log+In&redirect_to=https%3A%2F%2Fwordpress.com%2F&testcookie=1
";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url );
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, "https://wordpress.com/wp-login.php?redirect_to=https%3A%2F%2Fwordpress.com%2F");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);
echo $result;
exit;
?>
我使用代码:
http://localhost:8080/nexus?taskId=1&operatorId=3&version=10&day=12&hour=7&minute=3
我使用此代码进行测试:
path("nexus"){
get {
parameters('taskId.as[Int], 'operatorId.as[Int],'version.as[Int],'day.as[Int],'hour.as[Int] ,'minute.as[Int])
{ (taskId,operatorId,version,day,hour,minute) =>
complete{s"$taskId"}
}
}
但它导致了这个错误:
curl http://localhost:8080/nexus?taskId=1&operatorId=3&version=10&day=12&hour=7&minute=3
和operatorId确实存在!
我不知道怎么做!
答案 0 :(得分:0)
代码是正确的。只需用双引号包装URL:
curl "http://localhost:8080/nexus?taskId=1&operatorId=3&version=10&day=12&hour=7&minute=3"