Foxtable(狐表)用户栏目专家坐堂 → 自定义函数返回USERID


  共有2609人关注过本帖平板打印复制链接

主题:自定义函数返回USERID

帅哥哟,离线,有人找我吗?
bobolan521
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:632 积分:7217 威望:0 精华:1 注册:2013/11/26 7:49:00
自定义函数返回USERID  发帖心情 Post By:2017/4/28 23:15:00 [只看该作者]

请老师帮忙看一下,企业微信里运行后出现图片里的问题,企业微信里的可信域名为www.664748.com:8083
到底是哪里出了问题
Dim e As RequestEventArgs = args(0)
If e.host = "www.664748.com" Then '需要授权才能访问的域名
    If e.path = "aaa.htm"
        Dim UserId As String
        Dim UserName As String
        Dim sb As New StringBuilder
        sb.AppendLine("<meta name='viewport' c>")
        If e.GetValues.ContainsKey("code") Then '如果通过授权链接跳转而来,就根据传递过来的code参数调用接口,获取用户的UserId
            Dim ul As String  = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={0}&code={1}"
            ul = CExp(ul,Functions.Execute("GetQYAccessToken"),e.GetValues("code"))
            Dim hc As new HttpClient(ul)
            Dim jo As JObject = JObject.Parse(hc.GetData)
            If jo("UserId") IsNot Nothing Then
                UserId = jo("UserId")
            End If
        Else
            UserId = e.Cookies("userid") '否则从cookie中提取userid和username
        End If
        If UserId  > "" then'授权成功
            e.AppendCookie("userid",UserId) '将userid和username存储在Cookie中
            Dim u3 As String = "http://www.664748.com:8083/jiyekrs.htm"
            sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接
        ElseIf e.GetValues.ContainsKey("code") = False Then '如果授权失败,且不是通过授权链接跳转而来,那么就跳转到授权链接
            Dim ul1 As String = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=SCOPE&agentid=AGENTID&state=STATE#wechat_redirect"
            Dim ul2 As String = UrlEncode("http://www.664748.com:8083/aaa.htm")
            ul1 = CExp(ul1,"ww95bdb1894744965a",ul2)
            sb.Append("<meta http-equiv='Refresh' c>") '跳转到授权链接
          

            e.WriteString(sb.ToString)
            Return ""
        End If
        e.WriteString(sb.ToString)
    End If
End If

[此贴子已经被作者于2017/5/2 14:17:18编辑过]

 回到顶部
总数 11 1 2 下一页