当多个接口其实访问的url差不多的 情况下,思路就是传参数决定访问哪个接口最好
/** * 代码管理get数据 * 官方文档:https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1489140610_Uavc4&token=&lang=zh_CN * @param int $type * @return mixed */ public function getCodeConfig($type = 0) { $arr = [ 'get_qrcode',//获取体验小程序的体验二维码 'get_category',//获取授权小程序帐号已设置的类目 'get_page',//获取小程序的第三方提交代码的页面配置 'get_latest_auditstatus',//查询最新一次提交的审核状态 'revertcoderelease',//小程序版本回退 'undocodeaudit',//小程序审核撤回 ]; $url = self::WXA_URL. $arr[$type]. '?access_token='. $this->access_token; if ($type == 0) { $curl = $this->getCurl(); $curl->get($url); if (in_array('Content-Type: image/jpeg', $curl->response_headers)) { //返回图片 return [ 'code' => 0, 'file_path' => $this->saveTesterImg($curl->response), ]; } return json_decode($curl->response, true); } $data = $this->curlGet($url); return $data; }