$post_data['WIDout_trade_no'] = $_POST['trade_number'];
$post_data['WIDsubject'] = $_POST['trade_name'];
$post_data['WIDtotal_fee'] = $_POST['trade_price'];
$post_data['WIDbody'] = "付款问题请联系客服QQ/vx:768624766";


$url = './create_order/alipayapi.php';
$html_text=send_post($url,$post_data);
echo $html_text;
/**
* 模拟post进行url请求
* @param string $url
* @param array $post_data
*/


function send_post($url, $post_data) {
$postdata = http_build_query($post_data);
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => $postdata,
'timeout' => 15 * 60 // 超时时间(单位:s)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}

也有人喜欢用curl 不过主要是用线上的https地址测试

function curl_post($url, $post)
{
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post,
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书下同
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}