예제 #1
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    # result = send_sms(telephone,code)  # 调用发送短信短信任务
    # print(result)
    print(code)
    return restful.ok()
예제 #2
0
파일: views.py 프로젝트: cjmonkey/django
def sms_captcha(request):
    # result = aliyunsms.send_sms('17343041099', '1234')
    # print(result)

    # str = {
    #     "Message": "OK",
    #     "RequestID": "C1B15D4A-D99A-4569-A771-EE4619061CA0",
    #     "BizId": "630810229902863787^0",
    #     "Code":"OK",
    # }
    #
    # result = str;
    # print(result)


    # 接收手机号
    # /sms_captcha/?telephone=xxx
    telephone = request.GET.get('telephone')

    # 生成验证码
    # 调用图片验证码中的四位验证码
    code = Captcha.gene_text()

    # result = aliyunsms.send_sms(telephone, code)

    print(telephone, code)

    # 返回json数据格式的信息
    print(restful.ok())

    # 保存到memcached中
    cache.set(telephone, code, 60 * 5);

    return restful.ok();
예제 #3
0
def sms_captcha(request):
    telephone = request.GET.get("telephone")
    code = Captcha.gene_text()
    cache.set(telephone, code.lower(), 5 * 60)
    print("短信验证码:"+code)
    # result = aliyunsms.send_sms(telephone, code)
    return restful.ok()
예제 #4
0
def sms_captcha(request):
    # /sms_captcah/?telephone=xxx
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    aliyunsms.send_sms(phone_numbers=telephone, code=str(code))
    cache.set(telephone, code, 5*60)
    return restful.ok()
예제 #5
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    # result = Tecent_sms_send.send_sms(telephone,code)
    print('短信验证码:', code)
    return restful.ok()
예제 #6
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    print(code)
    # aliyunsms.send_sms(telephone, code)
    return restful.ok()
예제 #7
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    print('sms code =', code)
    # TODO: 应该动态生成,使用短信发送给用户,因阿里云SDK下载失败,以后再试
    cache.set(telephone, code, 5 * 60)
    print("telephone = ", telephone)
    return restful.ok()
예제 #8
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    # 在调试阶段为了方便就不发送验证码了,直接在控制台打印出来
    result = aliyunsms.send_sms(telephone, code)
    print(code)
    cache.set(telephone, code, 60)
    return restful.ok()
예제 #9
0
def sms_captcha(request):
    # /sms_captcha/?telephone=xxx
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    print('短信验证码:', code)
    # result = aliyunsms.send_sms(telephone,code)
    return restful.ok()
예제 #10
0
def sms_captcha(request):
    telepone = request.GET.get('telepone')
    code = Captcha.gene_text()
    cache.set(telepone, code, 5 * 60)
    print('短信验证码:', code)
    # result = smssender.send(telepone,code)
    # if result:
    return restful.ok()
예제 #11
0
def sms_captcha(request):
    #/sms_captcha/?telephone=xxx获取手机号
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    # result=smssender.send(mobile=telephone,captcha=code)
    print('短信验证码', code)
    return restful.success()
예제 #12
0
파일: views.py 프로젝트: Rousong/xfz
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    aliyunsms.send_sms(telephone, code)
    cache.set(telephone, code.lower(), 300)
    # 测试时打印短信验证码使用
    #print(f'短信验证码:{code.lower()}')
    return restful.ok()
예제 #13
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    # 暂时先不直接发短信验证码,省钱,实际用的时候再解除注释
    # result = aliyunsms.send_sms(telephone,code)
    cache.set(telephone, code, 5 * 60)
    # print(result)
    print(code)
    return restful.ok()
예제 #14
0
def sms_captcha(request):
    # result = demo_sms_send.send_sms('15313921315','666666')
    # print(result)
    #http://127.0.0.1:9000/sms_captcha?telephone=13777777777
    telephone = request.GET.get('telephone')  #接收手机号
    code = Captcha.gene_text()  #生成随机的字符
    cache.set(telephone, code, 5 * 60)  #然后放到了混存中
    print('短信验证码:', code)
    result = demo_sms_send.send_sms(telephone, code)  #发送给用户
    return restful.success()
예제 #15
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    result = send(telephone, code)
    print("短信验证码:", code)
    if result:
        return restful.result(data={'code': code})
    else:
        return restful.params_error(message="短信验证码发送失败!")
예제 #16
0
def sms_captcha(request):
    # 短信验证码
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    # result = aliyunsms.send_sms(telephone,code) 测试不开启
    # result = aliyunsms.send_sms('18855224160','1234')
    # print(result)
    print('短信验证码', code)
    return restful.ok()
예제 #17
0
파일: views.py 프로젝트: gaohj/1902_django
def sms_captcha(request):
    #接收手机号
    telephone = request.GET.get('telephone')
    #生成随机验证码
    code = Captcha.gene_text()  #调用captcha文件夹中的 Captcha类中的 gene_text方法 完成随机验证码
    #将验证码 放到memcached中 或者 session中
    cache.set(telephone, code, 5 * 60)
    print(code)
    result = aliyunsms.send_sms(telephone, code)
    return restful.success()
예제 #18
0
파일: views.py 프로젝트: fanyi055578/xfz
def send_phone(request):
    tel = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(tel,code,5*60)
    send_telephone(tel,code)
    print(code+'xxxx')
    captcha.append(code)
    cs = cache.get('code')
    print(cs)
    return restful.ok()
예제 #19
0
파일: views.py 프로젝트: qileDai/xfz
def sms_captcha(request):
    telephone = request.GET.get("telephone")
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    print("短信验证码:", code)
    # result = aliyunsms.send_sms(telephone,code)
    result = smssender.send(telephone, code)
    if result:
        return restful.ok()
    else:
        return restful.params_error(message="短信验证码发送失败")
예제 #20
0
 def get(self, request):
     telephone = request.GET.get('telephone')
     code = Captcha.gene_text()
     cache.set(telephone, code, ex=300)
     print(cache.get(telephone.lower()))
     return restful.ok()
     # result = sms_sender.send(telephone, code)
     # if result:
     #     return restful.ok()
     # else:
     #     return restful.params_errors(message='验证码发送失败')
예제 #21
0
파일: views.py 프로젝트: P79N6A/xfz
def sms_captcha(request):
    #电话号码
    telephone = request.GET.get('telephone')
    #随机验证码
    code = Captcha.gene_text()

    print(telephone)
    # 手机号为key,code为value
    cache.set(telephone, code, 5 * 60)
    res = aliyunsm.send_sms(telephone, 'baxu', template_code=code)
    print('xfzauth:views-line89,发送的短信验证码:', code)
    return restful.ok()
예제 #22
0
def sms_captcha(request):

    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)  # Expire: 5*60 seconds.
    # result = aliyunsms.send_sms(telephone, code)
    print(code)
    result = smssender.send(telephone, code)
    if result:
        return restful.ok()
    else:
        return result.params_error(message="短信验证码发送失败!")
예제 #23
0
def sms_captcha(request):
    # 通过GET获取用户提交上来的telephone
    telephone = request.GET.get('telephone')
    # 随机生成一个4为的验证码
    code = Captcha.gene_text()
    # 以telephone为key,以code为value,把手机验证码缓存在服务器的内存中
    cache.set(telephone, code, 2 * 60)
    # 通过阿里云短信服务给用户发送验证短信
    result = aliyunsms.send_Sms(telephone, code)
    print(result)
    print(code)
    return restful.ok()
예제 #24
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    cachecode = str(cache.get(code))
    print("cachecode:" + cachecode)
    print('短信验证码:' + code)
    # result = messageSender.send(telephone,code)
    # if result:
    #     return restful.ok()
    # else:
    #     return restful.params_error(message="短信验证码发送失败")
    return restful.ok()
예제 #25
0
파일: views.py 프로젝트: qDonl/xfz_front
def sms_captcha(request):
    # 短信验证码视图函数
    telephone = request.GET.get("telephone")
    exists = User.objects.filter(telephone=telephone).exists()
    if exists:
        return restfuls.bad_request(msg="该手机号已被注册!")

    captcha = Captcha.gene_text()
    cache.set(telephone, captcha.lower(), 5 * 60)
    print(f"""
    手机号码: {telephone}
    验证码: {captcha}
    """)
    return restfuls.success()
예제 #26
0
파일: views.py 프로젝트: jangocheng/xfz
def sms_captcha(request):
    # /sms_captcha/?telephone=xxx
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5*60)
    # CACHE.set(telephone, code, ex=5*60)
    print('短信验证码:', code)
    # result = smssender.send(telephone, code)
    result = aliyunsms.send_sms(telephone, code)
    # result = True
    if result:
        return restful.ok()
    else:
        return restful.params_error(message="短信验证码发送失败!")
예제 #27
0
파일: views.py 프로젝트: bujidaoei/xfz
def sms_captcha(request):
    # /sms_captcha/?telephone=xxx
    # 先获取短信发送到的手机号码
    telephone = request.GET.get('telephone')
    # 获取一个随机的验证码
    code = Captcha.gene_text()
    # 将短信验证码存储到memcached中,手机号为key,验证码为value,有效期也设置为5分钟
    cache.set(telephone,code,5*60)
    # 运用到生产环境要用下面这行代码来真正的发送短信验证
    # result = aliyunsms.send_sms(telephone,code)
    # 测试用
    # 写代码测试阶段如果每次测试注册功能都去发送短信验证就比较浪费钱,所以这里采用在控制台打印验证码的方式
    print('短信验证码:', code)
    return restful.ok()
예제 #28
0
파일: views.py 프로젝트: star-devil/ysk-web
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    # exists = SmsCaptcha.objects.filter(telephone=telephone).exists()
    # if exists:
    #     SmsCaptcha.objects.filter(telephone=telephone).update(captcha=code)
    # else:
    #     SmsCaptcha.objects.create(telephone=telephone, captcha=code)
    cache.set(telephone, code, 5*60)
    print('短信验证码', code)
    result = smssender.send(telephone, code)
    if result:
        return restful.ok()
    else:
        return restful.params_error(message='短信验证码发送失败!')
예제 #29
0
def sms_captcha(request):
    # /sms_captcha/?telephone=xxx
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone, code, 5 * 60)
    print('短信验证码:', code)
    # result = aliyunsms.send_sms(telephone,code)
    result = smssender.send(telephone, code)
    if result:
        return restful.ok()
    else:
        return result.params_error(message="短信验证码发送失败!")


#
# def cache_test(request):
#     cache.set('username','zhiliao',60)
#     result = cache.get('username')
#     print(result)
#     return HttpResponse('success')
예제 #30
0
파일: views.py 프로젝트: sanjie1/xfz
def sms_captcha(request):
    # /sms_captcha/?telephone=xxx
    telephone = request.GET.get('telephone')
    code = Captcha.gene_text()
    cache.set(telephone,code,5*60)
    print('短信验证码:',code)
    #result = aliyunsms.send_sms(telephone,code)
    return restful.ok()
    #测试
    # result=aliyunsms.send_sms('13877314974','1234')
    # print(result)
    # return HttpResponse('success')


#
# def cache_test(request):
#     cache.set('username','zhiliao',60)
#     result = cache.get('username')
#     print(result)
#     return HttpResponse('success')