public function test(){ $ch = curl_init(); $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx123456789&secret=32123456ergrgr54g7rgr"; curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $res = curl_exec($ch); curl_close($ch); //取出openid $data = json_decode($res,true); print_r($data);exit; }