微信接口开发中最常用的两个函数post和get

0 0 407

function getCurl($url){//get https的内容
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//不输出内容
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
curl_close ($ch);
return $result;
}

function dataPost($post_string, $url){
$context = array (
‘http’ => array (
‘method’ => “POST”,
‘header’ => “User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) \r\n Accept: */*”,
‘content’ => $post_string
)
);
$stream_context = stream_context_create ( $context );
@$data = file_get_contents($url,FALSE,$stream_context);
return $data;
}

留言

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>