$payment_no = $row['payment_no'];
$mchid = "******";
$serial_no = "********";
$nonce_str = bin2hex(random_bytes(16));
$timestamp = time();
$requestParams = [
'need_query_detail' => true,
'offset' => 0,
'limit' => 20,
'detail_status' => 'SUCCESS',
];
$url = "https://api.mch.weixin.qq.com/v3/transfer/batches/batch_id/{$payment_no}?" . http_build_query($requestParams);
$method = "GET";
$urlParts = parse_url($url);
$urlPath = $urlParts['path'] . (isset($urlParts['query']) ? '?' . $urlParts['query'] : '');
$message = $method . "\n" . $urlPath . "\n" . $timestamp . "\n" . $nonce_str . "\n";
$privateKeyPath = $_SERVER['DOCUMENT_ROOT']."/apiclient_key.pem";
$privateCertPath = $_SERVER['DOCUMENT_ROOT']."/apiclient_cert.pem";
$privateKey = file_get_contents($privateKeyPath);
openssl_sign($message, $signature, $privateKey, '*******');
$signature = base64_encode($signature);
$token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"',
$mchid, $nonce_str, $timestamp, $serial_no, $signature);
$headers = [
"Authorization: WECHATPAY2-SHA256-RSA2048 " . $token,
"Accept: application/json",
"User-Agent: PHP-CURL",
"Content-Type: application/json"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSLCERT, $privateCertPath);
curl_setopt($ch, CURLOPT_SSLKEY, $privateKeyPath);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
返回空,我应该如何排查原因
没有报错?