收藏
回答

openid 有些用户的能获取到,有些用户的获取不到,为什么?

问题模块
API和组件

openid 有些用户的能获取到,有些用户的获取不到,为什么?是用户做了什么设置吗?

最后一次编辑于  2017-11-15  (未经腾讯允许,不得转载)
回答关注问题邀请回答
收藏

4 个回答

  • 旅途
    旅途
    2017-11-15
    wx.request({
                                        url: 'https://cash.tosolomo.com/chwl_fz/add_wxuser_json',//自己的服务接口地址
                                        method: 'post',
                                        header: {
                                            'content-type': 'application/x-www-form-urlencoded'
                                        },
                                        data: { encryptedData: res.encryptedData, iv: res.iv, code: code },
                                        success: function (data) {
                                            that.globalData.uid = data.data;
                                            wx.setStorage({
                                                key: "uidkey",
                                                data: data.data,
                                                success: function (res) {
                                                    console.log(data.data)
                                                },
                                            })
                                        },
                                        fail: function () {
                                            console.log('系统错误')
                                        }
                                    })


    2017-11-15
    赞同
    回复
  • 旅途
    旅途
    2017-11-15
    include_once "wxaec/wxBizDataCrypt.php";
            $appid          = 'wxb85d603c6***';
            $secret         = '42c1a3cc9712666af2d60d***5';
     
            $js_code        = trim($this->input->post('code'));
            //$js_code      = "001iHwvE0k59Ve28tawE09PbvE0iHwvl";
            $encryptedData  = trim($this->input->post('encryptedData'));
            $iv             = trim($this->input->post('iv'));
     
            $url = "https://api.weixin.qq.com/sns/jscode2session?appid=
     
    ".$appid."&secret=".$secret."&js_code=".$js_code."&grant_type=authorization_code";
            $ch = curl_init();//初始化curl
            curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书 
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); // 检查证书中是否设置域名 
            curl_setopt($ch, CURLOPT_HEADER, TRUE);
            curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
            $wxdata = curl_exec($ch);//运行curl
            curl_close($ch);
            preg_match_all('/"session_key":"(.*)",/isU', $wxdata, $rct_array);

    2017-11-15
    赞同
    回复
  • 韦见。
    韦见。
    2017-11-15

    以前遇到过

    有些用户的昵称带emoji表情

    在解析时可能存在失败 或者 入库时数据库不支持导致写入失败

    2017-11-15
    赞同
    回复
  • 吴森
    吴森
    2017-11-15

    不会吧,贴代码

    2017-11-15
    赞同
    回复