接码例子_易码注册

Delay 3000
Import "ShanHai.lua"   //先下载山海插件,并放在插件目录 plugin 下
Dim api,username,password,token
api = "http://api.fxhyd.cn/UserInterface.aspx"//易码开发接口地址,请从易码官网查询当前可用的接口地址
username = ReadUIConfig("接码账号")
password = ReadUIConfig("接码密码")
token = ""//Token值,可以调用登录接口获取,也可以登录易码网站从个人中心首页复制
Dim itemid,province,city,isp,excludeno,release
itemid = "68"//项目编号,必须
province = "0"//指定号码归属地的省份代码,不需要请留空或者设置为0
city = "0"//指定号码归属地的城市代码,不需要请留空或者设置为0
isp = "0"//指定运营商,不需要请留空或者设置为0
excludeno = ""//要排除的号段,如:171|172|174|178,不需要排除号码留空即可
release = "1" //该值为1时,收到短信的同时自动释放号码
Dim 请求链接,易码返回值,手机号,验证码
Function 获取手机号码()
    Do
        If token <> "" Then 
            Exit Do 
        End If
    	
        If username = "" or password = "" Then 
            ShowMessage "易码账号或密码为空",3000
            EndScript
        End If

        TracePrint "登陆易码..."
        请求链接 = api & "?action=login&username=" & username & "&password=" & password
        TracePrint 请求链接
        易码返回值 = url.get(请求链接)
        TracePrint 易码返回值

        If 易码返回值 Then 
            Dim 返回参数 = Split(易码返回值,"|")
            If InStr(1, 易码返回值, "success") > 0 Then
                token = 返回参数(1)
                TracePrint "易码登陆成功:" & token ,3000
                Exit Do 
            ElseIf 易码返回值 = "1005" Then
                ShowMessage "用户名或密码错误", 3000
                EndScript
            ElseIf 易码返回值 = "1006" then
                ShowMessage "用户名不能为空", 3000
                EndScript
            ElseIf 易码返回值 = "1007" Then
                ShowMessage "密码不能为空",3000
                EndScript
            ElseIf 易码返回值 = "1009" Then
                ShowMessage "账户已被禁用", 3000
                EndScript
            Else
                TracePrint "易码登陆失败:" & 易码返回值 ,3000
            End If
        Else
            ShowMessage "暂时未连接到易码服务器,三秒后再次尝试",3000
        End If
    Loop

    Do
        TracePrint "获取手机号码..."
        请求链接 = api & "?action=getmobile&token=" & token & "&itemid=" & itemid & "&province=" & province & "&city=" & city & "&isp=" & isp & "&excludeno=" & excludeno
        TracePrint 请求链接
        易码返回值 = url.get(请求链接)
        TracePrint 易码返回值

        If 易码返回值 Then 
            If 易码返回值 = "1008" Then 
                ShowMessage "账号余额不足", 3000
            ElseIf 易码返回值 = "2004" Then
                ShowMessage "暂时没有可用的号码,三秒钟之后再次获取", 3000
            ElseIf 易码返回值 = "2005" Then
                ShowMessage "获取号码数量已达到上限",3000
            ElseIf InStr(1, 易码返回值, "success") > 0 Then
                Dim 手机 = Split(易码返回值,"|")
                手机号 = 手机(1)
                ShowMessage "获取手机号码" & 手机号 & "成功", 1000
                Delay 1000
                Exit Do
            Else
                TracePrint "获取手机号码失败:" & 易码返回值 ,3000
            End If
        Else 
            ShowMessage "暂时未连接到易码服务器,三秒后再次尝试",3000
        End If
        Delay 3000
    Loop
End Function

Function 获取验证码()
    TracePrint "获取短信..."
    Dim times = 0
    Do
        请求链接 = api & "?action=getsms&mobile=" & 手机号 & "&itemid=" & itemid & "&token=" & token & "&release=" & release
        TracePrint 请求链接
        易码返回值 = url.get(请求链接)
        TracePrint 易码返回值

        If 易码返回值 Then 
            If 易码返回值 = "3001" Then
                ShowMessage 手机号 & "正在获取验证码,将在"& 30 - times & "秒后超时",3000
                Delay 3000
                times = times + 1
            ElseIf InStr(1, 易码返回值, "success") > 0 Then
                ShowMessage 易码返回值,1000
                dim code = shanhai.RegexFind(易码返回值, "%d%d%d%d%d%d")  //%d%d%d%d%d%d 是6位验证码,根据自己的需求酌情调整验证码位数
                验证码 = code(0)
                ShowMessage 验证码,1000
                Exit Do
            Else 
                ShowMessage 手机号 & "获取短信失败:" & 易码返回值, 3000
                Delay 3000
            End If

            If times > 30 Then 
                ShowMessage 手机号 & "获取验证码超时", 3000
                Delay 3000
                Call 验证码超时()
            End If
        Else 
            ShowMessage "连接易码服务器异常,3秒后再次尝试", 3000
        End If
    Loop
End Function

Function 拉黑释放手机号码()
    TracePrint "拉黑释放手机号码..."
    请求链接 = api & "?action=addignore&mobile="& 手机号 &"&itemid="& itemid &"&token="& token
    TracePrint 请求链接
    易码返回值 = url.get(请求链接)
    TracePrint 易码返回值

    If 易码返回值 = "success" Then 
        ShowMessage "拉黑成功", 1000
        Delay 1000 
    Else 
        ShowMessage "拉黑释放手机号码失败:" & 易码返回值, 3000
    End If
End Function

Function 验证码超时()
    Call 拉黑释放手机号码()
        
End Function





Dim Val1
Val1 = ReadUIConfig ("多选框1")
If Val1 = True Then 
    ShowMessage "自动注册已勾选,开始注册", 1500
    Delay 3000
    Call 自动注册()
End If



//注册子程序
Sub 自动注册
  '注册的代码写这个
  
  
  
End Sub

 

赞 (0)