其实,也比较简单,上代码:
<?php <br><br> $url = 'http://127.0.0.1/test.php';//POST指向的链接 <BR> $data = array( <BR> 'access_token'=>'thekeyvalue' <BR> ); <br><br> $json_data = postData($url, $data); <BR> $array = json_decode($json_data,true); <BR> echo '<pre class="prettyprint linenums">';print_r($array); <br><br> function postData($url, $data) <BR> { <BR> $ch = curl_init(); <BR> $timeout = 300; <BR> <b style="color:transparent">来&源gao@dai!ma.com搞$代^码%网</b><img>搞gaodaima代码</img> curl_setopt($ch, CURLOPT_URL, $url); <BR> curl_setopt($ch, CURLOPT_REFERER, "http://www.gaodaima.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>