/** * 发送post请求 * @param string $url 请求地址 * @param array $post_data post数据 * @return string */ function send_post($url, $post_data) {$ch = curl_init($url);curl_setopt($ch, curlopt_customrequest, post);curl_setopt($ch, curlopt_po
/** * 发送post请求 * @param string $url 请求地址 * @param array $post_data post数据 * @return string */ function send_post($url, $post_data) { $ch = curl_init($url); curl_setopt($ch, curlopt_customrequest, post); curl_setopt($ch, curlopt_postfields,$post_data); curl_setopt($ch, curlopt_returntransfer,true); curl_setopt($ch, curlopt_httpheader, array( 'content-type: application/json', 'content-length: ' . strlen($post_data)) ); return curl_exec($ch); } oxs2nupceb836nrmrsxxxxxx, content => $send_msg); $data_string = json_encode($data); echo send_post('http://xxx.cn/api/wx/push/custom/text?mykey=xxxxxx', $data_string); ?>
原文地址:php:post发送json字符串, 感谢原作者分享。