/**
* 发送post请求
* @param string $url 请求地址
* @param array $post_data post键值对数据
* @return string
*/
function send_post($url, $post_data) {
$postdata = http_build_query($post_data);
$postdata = json_encode($post_data);
$options = array(
'http' => array(
'method' => 'POST',
//'header' => 'Content-type:application/x-www-form-urlencoded',
'header' => 'Content-type:application/json',
'content' => $postdata,
'timeout' => 15 * 60 // 超时时间(单位:s)
),
// 跳过https验证
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
//var_dump($result);return;
return $result;
}
function getContent($keyword = null) {
$send_post = [];
if (!empty($keyword)){
$url = 'https://jsonin.com/fenci.php';
$data = [
'type' => 'fenci',
'msg' => '客户提到医院网上负面信息,如何全方位反驳?'
];
//$data = json_encode($data);
$send_post = send_post($url,$data);
}
return $send_post;
}
getContent();
网友评论