$appid  = '';
$secret = $this->app;
$code = $_REQUEST['code'];
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$secret&js_code=$code&grant_type=authorization_code";
$ch = curl_init();
curl_setopt_array($ch,[
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_TIMEOUT=>5,
CURLOPT_SSL_VERIFYHOST=>false,
CURLOPT_URL=>$url,
]);
$res = curl_exec($ch);
curl_close($ch);
$data = json_decode($res,true);
echo json_encode(['openid'=>$data['openid']??'']);

Use HTTPS & validate errors; do not disable SSL in production.