Forráskód Böngészése

园区模糊搜索

chenhao 4 éve
szülő
commit
838f57fc84
1 módosított fájl, 11 hozzáadás és 4 törlés
  1. 11 4
      application/api/controller/User.php

+ 11 - 4
application/api/controller/User.php

@@ -143,25 +143,32 @@ class User extends Api
     }
     /**
      * 授权登录
-     * @param string $group_id 身份012
+     * @param string $js_code code
      */
     public function wechatLogin()
     {
         $data = input('get.');
         $appid = "wxe02aa578255f9184 ";
-        $secret = "39ec8add0b8d4ed794e9cb330a334538";
+        $secret = "5e184a450e2cb5331826ead2fd95157e";
         $js_code = $data['js_code'];
+        $headerArray = array(
+            "Content-type:application/json",
+            "Accept:application/json"
+        );
         $url = "https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$secret&js_code=$js_code&grant_type=authorization_code";
         $ch = curl_init();                             //初始化
         curl_setopt($ch, CURLOPT_URL, $url);           //设置访问的URL
         curl_setopt($ch, CURLOPT_HEADER, false);       //设置不需要头信息
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//只获取页面内容,但不输出
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    // 信任任何证
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);        // 表示不检查证书
+        curl_setopt($ch,CURLOPT_HTTPHEADER,$headerArray);
         $str = curl_exec($ch);                         //执行访问,返回结果
         curl_close($ch);                               //关闭curl,释放资源
+        dump($str);die;
         $openid = json_decode($str, true);
-        dump($openid);die;
         $data["user_openid"] = $openid["openid"];
-        dump($data);
+
     }
     /**
      * 重置密码