其实,也比较简单,上代码:
复制代码 代码如下:
$url = 'http://127.0.0.1/test.php';//post指向的链接
$data = array(
'access_token'=>'thekeyvalue'
);
$json_data = postdata($url, $data);
$array = json_decode($json_data,true);
echo '
';print_r($array); <br><br> function postdata($url, $data) <br> { <br> $ch = <a style="color:#f60; text-decoration:underline;" title="curl" href="https://www.php.cn/zt/17285.html" target="_blank">curl</a>_init(); <br> $timeout = 300; <br> curl_setopt($ch, curlopt_url, $url); <br> curl_setopt($ch, curlopt_referer, "http://www.bitscn.com/"); //构造来路 <br> curl_setopt($ch, curlopt_post, true); <br> curl_setopt($ch, curlopt_postfields, $data); <br> curl_setopt($ch, curlopt_returntransfer, 1); <br> curl_setopt($ch, curlopt_connecttimeout, $timeout); <br> $handles = curl_exec($ch); <br> curl_close($ch); <br> return $handles; <br> } <br>?><br>










