예제 #1
0
파일: api.py 프로젝트: WN199412/ceshi
def submit_phone(request):
    '''提交手机号,发送验证码'''
    # phone = request.POST.get('phone')
    phone = request.GET.get('phone')
    print(phone)
    send_sms(phone)
    return render_json(None)
예제 #2
0
def submit_phone(request):
    '''提交手机号,发送验证码'''
    if request.method == "GET":
        phone = request.GET.get('phone')
    else:
        phone = request.POST.get('phone')
    print(phone)
    send_sms(phone)
    return render_json(phone)
예제 #3
0
def user_phone(request):
    '''提交手机号,发送验证码'''
    phone = request.POST.get('phone')
    # phone = request.GET.get('phone')
    print(phone)
    send_sms(phone)

    #return 之后会经过Session 中间件的process_response
    return render_json(None)
예제 #4
0
def user_phone(request):
    '''提交手机号,发送验证码'''
    phone = request.POST.get('phone')
    # phone = request.GET.get('phone')
    print(phone)
    send_sms(phone)
    inf_log.info('vcode: ' + str(phone))

    # return 之后会经过 Session 中间件的 process_response 处理
    return render_json(None)
예제 #5
0
    def resend_sms(self, request, queryset):
        payments = []
        for item in queryset:
            try:
                card = BillserviceCard.objects.get(login=item.login)
                send_sms(item.phone.strip(), SMS_TXT % (card.login, card.pin))
                payments.append(str(item.id))
            except BillserviceCard.DoesNotExist:
                pass

        self.message_user(request, u"SMS переотправлен для: %s" % (','.join(payments),))
        return HttpResponseRedirect(request.get_full_path())
예제 #6
0
def submit_phone(request):
    '''获取短信验证码'''
    if not request.method == 'POST':
        return render_json('request method error', error.REQUEST_ERROR)
    phone = request.POST.get('phone')
    result, msg, vcode = send_sms(phone)
    print(vcode)
    return render_json(msg)
예제 #7
0
def submit_phone(request):
    if not request.method == "POST":
        return render_json('request method error',errors.REQUEST_ERROR)

    phone = request.POST.get('phone')
    result,msg = send_sms(phone)

    return render_json(msg)
예제 #8
0
파일: api.py 프로젝트: blackmambaha/swiper
def sumbit_phone(request):
    """"获取短信验证码"""
    if not request.method == 'POST':
        return render_json('request method error', errors.REQUEST_ERROR)

    phone = request.POST.get('phone')
    result, msg = send_sms(phone)

    return render_json(msg)
예제 #9
0
파일: api.py 프로젝트: wangxs35/test
def submit_phone(request):
    """获取短信验证码"""
    if not request.method == "POST":
        return HttpResponse('request method error')

    phone = request.POST.get('phone')
    result, msg = send_sms(phone)

    return render_json(msg)
예제 #10
0
def summit_phone(request):
    """提交手机号码, 发送验证码"""
    phone = request.POST.get('phone')
    # 发送验证码
    status, msg = send_sms(phone)
    if not status:
        return JsonResponse({'code': erros.SMS_ERROE, 'data': '短信发送失败'})
    else:
        # 发送成功
        return JsonResponse({'code': 0, 'data': None})
예제 #11
0
def s_sms(request):
    phone_num = request.POST.get('phone')
    vcode = cache.get(keys.SMS_KEY % phone_num, None)
    if vcode:
        raise errors.Sms_Error.SMS_TIME_LIMIT
    vcode = send_sms(phone_num)
    # 把验证码放到缓存中,过期时间60秒
    cache.set(keys.SMS_KEY % phone_num, vcode, 60)
    # print(phone_num)
    return render_json({"vcode": vcode})
예제 #12
0
파일: api.py 프로젝트: HFOrg/hfswiper
def submit_phone(request):
    """提交手机号码, 发送验证码"""
    phone = request.POST.get('phone')
    # 发送验证码
    status, msg = send_sms(phone)
    if not status:
        # return JsonResponse({'code': errors.SMS_ERROR, 'data': '短信发送失败'})
        return render_json(code=errors.SMS_ERROR, data='短信发送失败')
    # 发送成功.
    # return JsonResponse({'code': 0, 'data': None})
    return render_json()
예제 #13
0
파일: api.py 프로젝트: ModKanda/swiper
def submit_phone(request, code=0):
    """获取短信验证码"""
    if not request.method == 'POST':
        return render_json('request method error', errors.REQUEST_METHOD_ERROR)
    else:
        phone = request.POST.get('phone')
        #发送信息,将结果和信息返回
        result, msg = send_sms(phone)
        # print(msg)
        # return JsonResponse({'status':'ok','msg':msg})

        return render_json(msg)
예제 #14
0
파일: api.py 프로젝트: JackMikle/swiper11
def submit_phone(request):
    """获取短信验证码"""
    if not request.method == "POST":
        return render_json('request method error', errors.REQUEST_ERROR)

    phone = request.POST.get('phone')
    result, msg = send_sms(phone)

    # return JsonResponse({'status':'ok','msg':msg})
    data = {'status': 'ok', 'msg': msg}
    result = json.dumps(data)
    return HttpResponse(result)
예제 #15
0
파일: api.py 프로젝트: ccc179/swiper
def submit_phone(request):
    """获取短信验证码"""
    if not request.method == "POST":
        '''每次都可以去lib里面的http调用render_json帮助返回json 
            这个函数要传一个msg和一个状态码code
        '''
        return render_json("request error",code=errors.REQUEST_ERROR)
    else:
        # 从post请求里面拿到手机号,将手机号交给send_sms函数去发短信.
        phone = request.POST.get('phone')
        result, msg = sms.send_sms(phone)
        print(result)
        return render_json(msg)
예제 #16
0
파일: admin.py 프로젝트: varikgit/wifi
    def payment_process(self, request, queryset):
        for payment in queryset:
            if payment.service_id == 1:  # пополнение счета
                trn = Billservice_transaction()
                trn.bill = 'Пополнение счета через Comepay'
                trn.account = payment.account
                trn.type_id = 'COMEPAY_PAYMENT'
                trn.approved = True
                trn.tarif_id = 8
                trn.summ = payment.sum
                trn.description = "Comepay payment"
                trn.save()

            elif payment.service_id == 2:
                log.add("2.1 comepay_manual card")
                card = None
                from cards.models import BillserviceCard
                if payment.login:
                    log.add("2.1 comepay_manual card exists")
                    card = BillserviceCard.objects.get(login=payment.login.strip())
                else:
                    try:
                        log.add("2.1 comepay_manual card generate")
                        """Получаем логин и пароль для карты доступа на указанную сумму"""
                        card = BillserviceCard.generate_card(float(payment.sum), '1')
                        payment.login = card.login
                        payment.save()
                    except Exception, e:
                        log.add("2.1 comepay_manual card generate except: %s" % e)
                        login = password = ''

                if card:
                    login, password = card.login, card.pin
                if login and password:
                    log.add("2.1 comepay_manual send sms")
                    from lib.sms import send_sms
                    from payment.settings import SMS_TXT
                    send_sms(str(payment.pay_account).strip(), SMS_TXT % (login, password))
                    log.add("2.1 comepay_manual send sms success")
예제 #17
0
파일: main.py 프로젝트: heathf/get_forecast
def main(city="lander", sms_to=None, out_file=False):
	"""
	This main function will output our NWS weather results to the console, a Text message or an HTML file. If
	``sms_to`` is not null, it will attempt to send the SMS to the specified number. If ``out_file`` is present
	it will write the results to an HTML file on the Desktop. If neither ``sms_to`` or ``out_file`` is present,
	the results will be written to the console.

	It should be noted that only ``sms_to`` OR ``out_file`` can be present but not both.

	:param sms_to: (str) This should be a phone number, but passed as a string
	:return: (None) The message will be sent appropriately but no return value
	"""
	logger = set_logger()
	logger.debug("**********************    Script Started    **********************")

	if sms_to and out_file:
		err_msg = "You can pass ``sms_to`` OR ``out_file``, but not both"
		logger.error(err_msg)
		raise Exception(err_msg)

	weather_request = weather.WeatherRequest(city)
	response = weather_request.get_weather_request()

	logger.debug("Received the following response from the NWS call: {}".format(response))

	if sms_to:
		logger.info("Sending SMS message to the following number: {}".format(sms_to))
		sms.send_sms(sms_to, _convert_msg(response, True))
	elif out_file:
		html = html_file.HtmlFile(response)
		logger.info("Writing NWS data to HTML file")
		output_file = html.write_html_file()
		print "The HTML file has been written to: {}".format(output_file)
	else:
		logger.info("Sending NWS data to console")
		print(_convert_msg(response))
예제 #18
0
파일: qiwiapi.py 프로젝트: varikgit/wifi
                except Exception, e:
                    # log.info("except in row 292: %s" % e)
                    log.info("Exception in qiwiapi: '%s'" % e)
                    exc_type, exc_obj, exc_tb = sys.exc_info()  # @UnusedVariable
                    fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                    log.info("Exception in qiwiapi: file:%s line:%s" % (fname, exc_tb.tb_lineno))
                    continue

                log.info(u'TUT" %s' % x[7])
                if x[7]:
                    try:
                        log.info(u'TUT1')
                        num = '7' + x[7] if len(x[7]) == 10 else x[7]
                        from payment.settings import SMS_TXT
                        from lib.sms import send_sms
                        r = send_sms(num, SMS_TXT % (login, password), log=log)
                        if not r:
                            log.info(u'Error send sms')
                            # print u'Невозможно произвести платеж, ошибка отправки логина и пароля карты на указанный номер'
                        else:
                            log.info(u'SMS succesfully send')
                    except Exception, e:
                        log.info('1 %s' % e)
                        # print u'Except Невозможно произвести платеж, ошибка отправки логина и пароля карты на указанный номер'
                if x[6]:
                    try:
                        from lib.mail import send_email
                        from django.template import Template, Context
                        mail_context = {'summ' : x[2],
                                        'password': password,
                                        'login': login}
예제 #19
0
파일: views.py 프로젝트: varikgit/wifi
                    card = BillserviceCard.generate_card(float(inv.amount), '1')
                    login, password = card.login, card.pin
                    log.add(u"payment_wm login=%s password=%s" % (login, password))
                else:
                    login = password = '******'

            except Exception, e:
                log.add(u"payment_wm Except: %s" % e)
                raise WMError(u"Ошибка получения логина, пароля для карты")

            if not payment_settings.TEST_WM:
                if inv.payer_phone_number:
                    try:
                        num = inv.payer_phone_number if len(inv.payer_phone_number) == 11 else '7' + inv.payer_phone_number
                        from lib.sms import send_sms
                        r = send_sms(num, payment_settings.SMS_TXT % (login, password), log=log)
                        if not r:
                            raise WMError(u'Ошибка отправки логина и пароля карты на указанный номер')
                    except Exception, e:
                        log.add(u"payment_wm Except: %s" % e)
                        raise WMError(u'Ошибка отправки логина и пароля карты')
            if inv.payer_email:
                mail_context = {'summ' : inv.amount,
                                'password': password,
                                'login': login}
                subject = Template(payment_settings.MAIL_SUBJECT).render(Context(mail_context))
                text = Template(payment_settings.MAIL_TEXT).render(Context(mail_context))
                send_email(subject, text, settings.DEFAULT_FROM_EMAIL, [inv.payer_email])
                log.add(u'payment_wm Email succesfully send')
            try:
                # Сохраняем информацию по платежу в БД
예제 #20
0
                    log.info("Exception in qiwiapi: '%s'" % e)
                    exc_type, exc_obj, exc_tb = sys.exc_info()  # @UnusedVariable
                    fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
                    log.info("Exception in qiwiapi: file:%s line:%s" % (fname, exc_tb.tb_lineno))
                    continue

                log.info(u'TUT" %s' % x[7])
                if x[7]:
                    try:
                        log.info(u'TUT1')
                        num = x[7].strip()
                        if num.startswith('8') and len(num) == 11:
                            num = '7' + num[1:]
                        from payment.settings import SMS_TXT
                        from lib.sms import send_sms
                        r = send_sms(num.strip(), SMS_TXT % (login, password), log=log)
                        if not r:
                            log.info(u'Error send sms')
                            # print u'Невозможно произвести платеж, ошибка отправки логина и пароля карты на указанный номер'
                        else:
                            log.info(u'SMS succesfully send')
                    except Exception, e:
                        log.info('1 %s' % e)
                        # print u'Except Невозможно произвести платеж, ошибка отправки логина и пароля карты на указанный номер'
                if x[6]:
                    try:
                        from lib.mail import send_email
                        from django.template import Template, Context
                        mail_context = {'summ' : x[2],
                                        'password': password,
                                        'login': login}
예제 #21
0
def robokassa_result(request):
    if request.POST:
        log.add(u"robokassa_result POST: %s" % str(request.POST))
        out_summ = request.POST.get("OutSum")
        inv_id = request.POST.get("InvId")
        crc = request.POST.get("SignatureValue")
        shp_accountid = request.POST.get("Shp_accountid")
        opertype = request.POST.get("Shp_operationtype")

        if out_summ and inv_id and crc and opertype:
            try:
                pass2 = "ndjhtw1qaz"
                inv_id_int = int(inv_id)
                int_opertype = int(opertype)
                in_rk = Invoice_rk.objects.get(pk=inv_id_int, type=int_opertype, end=False)
                if int_opertype == 1:
                    str_to_md = out_summ + ":" + inv_id + ":" + pass2 + ":Shp_accountid=" + shp_accountid + \
                                ":Shp_operationtype=" + opertype
                else:
                    str_to_md = out_summ + ":" + inv_id + ":" + pass2 + \
                                ":Shp_operationtype=" + opertype
                m = hashlib.md5()
                m.update(str_to_md)
                if m.hexdigest().upper() == crc and in_rk.id:
                    if int_opertype == 1:

                        trn = Billservice_transaction()
                        trn.bill = in_rk.desc
                        trn.account = in_rk.account
                        trn.type_id = 'ROBOKASSA_PAYMENT'
                        trn.approved = True
                        trn.tarif_id = 0
                        trn.summ = in_rk.amount
                        trn.description = in_rk.desc
                        trn.save()

                        in_rk.transaction_id = trn.id
                        in_rk.end = True
                        in_rk.save()

                        response = HttpResponse("OK" + inv_id, content_type="text/plain")
                        log.add(u"payment_robokassa_end success inv_id: " + inv_id)
                    else:
                        #------------------------------------------
                        try:
                            if not payment_settings.TEST_RK:
                                """Получаем логин и пароль для карты доступа на указанную сумму"""
                                # login, password = get_card2(float(inv.amount), WM_DEALER_ID)
                                from cards.models import BillserviceCard
                                card = BillserviceCard.generate_card(float(in_rk.amount), '1')
                                login, password = card.login, card.pin
                                log.add(u"payment_wm login=%s password=%s" % (login, password))
                            else:
                                login = password = '******'

                        except Exception, e:
                            log.add(u"Ошибка получения логина, пароля для карты: %s:" % e)

                        if not payment_settings.TEST_RK:
                            if in_rk.payer_phone_number:
                                try:
                                    num = in_rk.payer_phone_number
                                    from lib.sms import send_sms
                                    r = send_sms(num, payment_settings.SMS_TXT % (login, password), log=log)
                                    if not r:
                                        log.add(u'Ошибка отправки логина и пароля карты на указанный номер')
                                except Exception, e:
                                    log.add(u'Ошибка отправки логина и пароля карты на указанный номер %s' % e)
                        if in_rk.payer_email:
                            mail_context = {'summ' : in_rk.amount,
                                            'password': password,
                                            'login': login}
                            subject = Template(payment_settings.MAIL_SUBJECT).render(Context(mail_context))
                            text = Template(payment_settings.MAIL_TEXT).render(Context(mail_context))
                            send_email(subject, text, settings.DEFAULT_FROM_EMAIL, [in_rk.payer_email])
                            log.add(u'card_rk Email succesfully send')
                        in_rk.login = login
                        in_rk.end = True
                        in_rk.save()
                        #------------------------------------------
                        response = HttpResponse("OK" + inv_id, content_type="text/plain")
                        log.add(u"card_robokassa_end success inv_id: " + inv_id)

                else:
                    log.add(u"payment_robokassa_end uncorrect md5 summ")
                    response = HttpResponse("FAIL", content_type="text/plain")
            except ValueError as e:
                log.add(u"payment_robokassa_end returns ValueError trying int() convertation. Except: %s" % e.message)
                response = HttpResponse("FAIL", content_type="text/plain")