Пример #1
0
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="短信验证码发送失败")
Пример #2
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="短信验证码发送失败!")
Пример #3
0
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='短信验证码发送失败!')
Пример #4
0
def sms_captcha(request):
    telephone = request.GET.get('telephone')
    #获取一个随机验证码
    # code = Captcha.gene_text()
    code1 = random.randint(1000, 9999)
    code = str(code1)
    # print(code)
    # code+=''
    print(type(code))
    #将telephone,code存到memcached,过期时间5分钟
    cache.set(telephone, code, 5 * 60)
    print("验证码", code)
    # return restful.ok()
    result = smssender.send(telephone, code)
    if result:
        return restful.ok()
    else:
        return restful.params_error(message="短信验证码失败")
Пример #5
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')
Пример #6
0
def send_sms_captcha(telephone, captcha):
    smssender.send(telephone, captcha)