-1, 'msg'=>'授权码有误']; } if(empty($params['config'])) { return ['status'=>-1, 'msg'=>'配置有误']; } // 获取授权 $url = 'https://developer.toutiao.com/api/apps/jscode2session?appid='.$params['config']['appid'].'&secret='.$params['config']['secret'].'&code='.$params['authcode']; $result = json_decode(file_get_contents($url), true); if(empty($result['openid'])) { return ['status'=>-1, 'msg'=>$result['errmsg']]; } return ['status'=>0, 'msg'=>'授权成功', 'data'=>$result]; } /** * 支付签名生成 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 * @date 2019-10-29 * @desc description * @param [array] $data [需要生成签名的数据] * @param [string] $secret [密钥] */ public function PaySignCreated($data, $secret) { ksort($data); $sign = ''; foreach($data AS $key=>$val) { if($key != 'sign' && $key != 'risk_info' && $val != '') { $sign .= "$key=$val&"; } } $sign = substr($sign, 0, -1); return md5($sign.$secret); } } ?>