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()
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();
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()
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()
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()
def img_captcha(request): text,image = Captcha.gene_code() # image,需要放到流中放回,不能放到HTTPResponse中 # BytesIO相当于一个管道,用来存储图片的流数据 out = BytesIO() # 将数据写到BytesIO,类型是png image.save(out, 'png') # 移动文件指针 out.seek(0) response = HttpResponse(content_type='image/png') # 从BytesIO中将数据读取出来,保存到 response 对象上 response.write(out.read()) # out.tell()获取当前指针的尾椎,就能知道文件大小 response['Content-length'] = out.tell(); # 保存到memcached中 cache.set(text.lower(), text.lower(), 60*5); return response
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()
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()
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()
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()
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()
def sms_captcha(request): """短信验证码""" telephone = request.GET.get("telephone") code = Captcha.gene_number() cache.set(telephone, code, 10*60) # result = aliyunsms.send_sms(telephone, code) print("短信验证码:", code) return restful.ok()
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()
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()
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()
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="短信验证码发送失败!")
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()
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()
def get(self, request): text, image = Captcha.gene_code() out = BytesIO() image.save(out, 'png') out.seek(0) response = HttpResponse(content_type='image/png') response.write(out.read()) response['Content-length'] = out.tell() cache.set(text.lower(), text.lower(), ex=300) return response
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()
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()
def image_captcha(request): text, image = Captcha.gene_code() out = BytesIO() image.save(out, 'png') out.seek(0) response = HttpResponse(content_type="image/png") response.write(out.read()) response['Content-length'] = out.tell() return response
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="短信验证码发送失败")
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='验证码发送失败')
def img_captcha(request): """验证码图片""" text, image = Captcha.gene_code() out = BytesIO() image.save(out, "png") out.seek(0) response = HttpResponse(content_type="image/png") response.write(out.read()) response["Content-length"] = out.tell() cache.set(text.lower(), text.lower(), 10 * 60) return response
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()
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="短信验证码发送失败!")
def img_captcha(request): text, image = Captcha.gene_code() out = BytesIO() # ByteIO用于存储字节 image.save(out, 'png') # 将验证码图片暂存于ByteIO out.seek(0) # 将ByteIO读写指针归零 resp = HttpResponse(content_type='image/png') resp.write(out.read()) # 将ByteIO中的字节读取并写给HttpResponse resp['Content-length'] = out.tell() cache.set(text.lower(), text.lower(), 5 * 60) # 缓存验证码 return resp
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()
def img_captcha(request): text,image = Captcha.gene_code() # BytesIO相当于一个管道,用来存储图片的流数据 out = BytesIO() # 调用image的save方法,将照片存储到BytesIO中 image.save(out, 'png') # 将BytesIO的文件指针移动到最开始位置 out.seek(0) response = HttpResponse(content_type='image/png') # 从BytesIO的管道中,读取出图片数据,保存到response对象上 response.write(out.read()) response['Content-length'] = out.tell() return response