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;
}

 

发表评论

您的电子邮箱地址不会被公开。