The problem of obtaining the official account access_token of Wechat by PHP

Why does PHP use curl to get access_token, display is empty, while file_get_contents to get access_token can show

$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx3225919883125899&secret=5913d164a3660264868de68ca02884f2";
/*$ch = curl_init ();
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
curl_close ($ch) * /

)

$res = file_get_contents ($url);

Feb.27,2021

curl_setopt($ch, CURLOPT_POST, 1);

your curl uses post,access_token and get


your curl code sends a post request, and file_get_contents sends a get request. This Wechat interface should be a get request

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be5933-31782.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be5933-31782.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?