<?php
/**
* 模拟post进行url请求
* @param string $url
* @param array $post_data
*/
function request_post($url = '', $post_data = array()) {
if (empty($url) || empty($post_data)) {
return false;
}
$o = "";
foreach ( $post_data as $k => $v )
{
$o.= "$k=" . $v . "&" ;
}
$post_data = substr($o,0,-1);
$postUrl = $url;
$curlPost = $post_data;
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/plain; charset=utf-8'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//运行curl
curl_close($ch);
return $data;
}
if ($_POST){
$czurl = "http://118.24.62.126:10003/paycb";
$roleid = $_POST['roleid'];
$czid = $_POST['czid'];
$data = array(
"playerId" => $roleid,
"productId" => $czid,
);
$result = request_post($czurl,$data);
var_dump($result);
}
?>
<html xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>啥玩应的充值工具</title>
</head>
<body>
<form method="post" action="">
角色ID:<input type="text" name="roleid"></br>
选择充值套餐:<select name="czid">
<option value="com.cilu.dhxx.gold_6">60元宝</option>
<option value="com.cilu.dhxx.gold_30">300元宝</option>
<option value="com.cilu.dhxx.gold_68">680元宝</option>
<option value="com.cilu.dhxx.gold_98">980元宝</option>
<option value="com.cilu.dhxx.gold_198">1980元宝</option>
<option value="com.cilu.dhxx.gold_328">3280元宝</option>
<option value="com.cilu.dhxx.gold_488">4880元宝</option>
<option value="com.cilu.dhxx.gold_648">6480元宝</option>
<option value="com.cilu.dhxx.giftbag_1">1元礼包</option>
<option value="com.cilu.dhxx.giftbag_3">3元礼包</option>
<option value="com.cilu.dhxx.giftbag_6">6元礼包</option>
<option value="com.cilu.dhxx.giftbag_10">10元礼包</option>
<option value="com.cilu.dhxx.giftbag_60">60元礼包</option>
<option value="com.cilu.dhxx.grow_68">一本万利680</option>
<option value="com.cilu.dhxx.grow_88">一本万利880</option>
<option value="com.cilu.dhxx.grow_98">一本万利980</option>
</select></br>
<button type="submit">充值</button>
</form>
</body>
</html>
这命令是点一次就执行一次,想改成点一次执行多次,就是充值一次才充648,想改成多次执行的。点一次执行10次 求大神帮下忙