php 模拟提交post数据

7 10 月
function send_post($url, $post_data) {
	$o = '' ;
	foreach ($post_data as $k => $v) {
		$o .= $k . '=' . urlencode ($v) . '&';
	}
	$post_data = substr($o, 0, -1);
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
	$result = curl_exec ($ch);
	curl_close($ch);
	return $result;
}

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注