微信公众号自动回复消息-Django实现

2024年1月8日 21:52 by wst

公众号开发

公众号开发中根据实际需求,要自动回复用户的消息。今天研究了下,实现方法如下。


@csrf_exempt
def receive(request):
    "接收微信公众号消息"
    if request.method == 'GET':
        token = WX_TOKEN # 设置自定义的Token值
        print("GETParameters:", request.GET)

        signature = request.GET.get('signature')
        timestamp = request.GET.get('timestamp')
        nonce = request.GET.get('nonce')
        echostr = request.GET.get('echostr')

        tmp_list = [token, timestamp, nonce]
        tmp_list.sort()
        tmp_str = "".join(tmp_list).encode("utf-8")
        sha1 = hashlib.sha1(tmp_str).hexdigest()

        if sha1 == signature:
            return HttpResponse(echostr)
        else:
            return HttpResponse('')
    elif request.method == 'POST':
        xml_data = request.body
        xml_dic = xmltodict.parse(xml_data)
        print("xml_data:", xml_data)
        print("xml_dict:", xml_dic)
        resp_dict = {
            'ToUserName': xml_dic['xml']['FromUserName'],
            'FromUserName': xml_dic['xml']['ToUserName'],
            'CreateTime': int(time.time()),
            'MsgType': 'text',
            'Content': xml_dic['xml']['Content']
        }
        resp_xml = xmltodict.unparse({'xml': resp_dict})
        return HttpResponse(resp_xml, content_type='text/xml')

只是列出了核心代码,看不懂老铁可以评论区留言。


Comments(126) Add Your Comment

Vnbpxa
buy atorvastatin cheap <a href="https://lipiws.top/">atorvastatin 10mg brand</a> lipitor 80mg oral
Zeaxzg
buy cipro 500mg generic - <a href="https://cipropro.top/keflexcapsule/">keflex brand</a> clavulanate us
Ndsjvu
buy baycip online cheap - <a href="https://metroagyl.top/oxytetracycline/">myambutol for sale online</a> buy generic augmentin over the counter
Amdtpr
buy flagyl medication - <a href="https://metroagyl.top/keflexcapsule/">amoxil pills</a> brand zithromax 500mg
Meqgqf
ciprofloxacin 500mg ca - <a href="https://septrim.top/tinidazole/">buy tindamax no prescription</a> buy erythromycin cheap
Mpatue
order valtrex 500mg - <a href="https://gnantiviralp.com/">valtrex uk</a> acyclovir for sale
Wihqee
ivermectin india - <a href="https://keflexin.top/cefixime/">buy suprax 100mg generic</a> order sumycin online
Nelkgr
how to buy metronidazole - <a href="https://metroagyl.top/">buy metronidazole no prescription</a> azithromycin 250mg ca
Fgmfug
buy ampicillin online cheap <a href="https://ampiacil.top/doxycyclineantb/">acticlate brand</a> purchase amoxil without prescription
Kgsxpu
order furosemide 100mg pill - <a href="https://antipathogenc.com/medex/">buy generic medex</a> buy captopril without prescription
Jnqhbo
cheap glucophage - <a href="https://gnantiacidity.com/combivir/">cheap epivir</a> generic lincomycin 500mg
Cucebt
retrovir pills - <a href="https://canadiangnp.com/zyloprim/"></a> allopurinol 300mg over the counter
Cebicg
order clozaril 50mg sale - <a href="https://genonlinep.com/pepcid/">purchase pepcid online</a> generic pepcid 20mg
Mutegs
where can i buy seroquel - <a href="https://gnkantdepres.com/zoloft/">order sertraline 100mg sale</a> where to buy eskalith without a prescription
Ioarhx
clomipramine 50mg price - <a href="https://antdeponline.com/abilify/">purchase abilify generic</a> buy sinequan 25mg online cheap
Wblpgb
generic atarax 25mg - <a href="https://antdepls.com/lexapro/">lexapro 20mg pills</a> amitriptyline 25mg sale
Fjoscb
order amoxiclav without prescription - <a href="https://atbioinfo.com/ampicillin/">ampicillin medication</a> buy cipro for sale
Otpsfm
buy amoxil for sale - <a href="https://atbioxotc.com/cefadroxil/">duricef 500mg ca</a> buy ciprofloxacin 500mg
Kxjzqy
buy clindamycin generic - <a href="https://cadbiot.com/cefixime/">where to buy cefixime without a prescription</a> buy chloromycetin pill
Ozttwg
buy zithromax 250mg without prescription - <a href="https://gncatbp.com/emetronidazole/">metronidazole cheap</a> ciprofloxacin 500mg tablet
Hsdhid
ivermectin pills - <a href="https://antibpl.com/ascefaclor/">buy cefaclor 500mg online cheap</a> order cefaclor 250mg generic
Xpgsta
albuterol for sale - <a href="https://antxallergic.com/advairdiskus/">buy fluticasone</a> theo-24 Cr drug
Mbnart
clarinex drug - <a href="https://rxtallerg.com/ventolinpill/">strongest over the counter antihistamine</a> order albuterol 2mg generic
Yinvlm
medrol cost in usa - <a href="https://ntallegpl.com/loratadine/">loratadine 10mg brand</a> astelin without prescription
Zsukfi
micronase cost - <a href="https://prodeprpl.com/pioglitazone30/">pioglitazone generic</a> buy generic forxiga
Unfdfw
how to get prandin without a prescription - <a href="https://depressinfo.com/jardiance25/">empagliflozin cost</a> empagliflozin 10mg usa
Uywcmz
buy metformin 500mg sale - <a href="https://arxdepress.com/acarbose50/">order acarbose sale</a> brand precose 25mg
Ghlktg
buy generic terbinafine - <a href="https://treatfungusx.com/adiflucanv/">forcan brand</a> where to buy griseofulvin without a prescription
Cbawdk
semaglutide 14mg brand - <a href="https://infodeppl.com/">order rybelsus 14 mg generic</a> DDAVP usa
Cpndhh
purchase nizoral - <a href="https://antifungusrp.com/butenafinecream/">butenafine order online</a> order itraconazole 100mg sale
Zmruvo
buy cheap famvir - <a href="https://amvinherpes.com/gnvalaciclovir/">valcivir 500mg for sale</a> valcivir canada
Rpfcke
buy generic digoxin online - <a href="https://blpressureok.com/isoptinpillmg/">buy calan 120mg</a> order furosemide 100mg sale
Mrngoh
purchase microzide generic - <a href="https://norvapril.com/felodipine/">order plendil online</a> buy zebeta 5mg online
Tsndzr
metoprolol 100mg for sale - <a href="https://bloodpresspl.com/propranolol/">order inderal without prescription</a> buy nifedipine generic
Ciimtd
buy generic nitroglycerin online - <a href="https://nitroproxl.com/clonidinechlorthalidone/">purchase combipres for sale</a> brand valsartan
Ccqmyn
rosuvastatin joke - <a href="https://antcholesterol.com/pravastatin/">pravachol buy companion</a> caduet account
Ndxnyq
simvastatin share - <a href="https://canescholest.com/atorvastatin/">atorvastatin firebolt</a> atorvastatin broom
Snqfkg
viagra professional online bring - <a href="https://edsildps.com/eriacta/">eriacta firm</a> levitra oral jelly behind
Oqjwks
priligy channel - <a href="https://promedprili.com/fildena/">fildena pilot</a> cialis with dapoxetine endure
Qlwhmj
cenforce steer - <a href="https://xcenforcem.com/">cenforce online curtain</a> brand viagra hopeful
Uadhtf
brand cialis kid - <a href="https://probrandtad.com/brandlevitra/">brand levitra england</a> penisole carpet
Gpnxoh
cialis soft tabs online positive - <a href="https://supervalip.com/viagrasuperactive/">viagra super active darkness</a> viagra oral jelly online port
Kcqizv
brand cialis employ - <a href="https://probrandtad.com/apcalissx/">apcalis rifle</a> penisole everybody
Xrkcod
cialis soft tabs pills speak - <a href="https://supervalip.com/viagraoraljelly/">viagra oral jelly gradual</a> viagra oral jelly online put
Bwswlh
cenforce record - <a href="https://xcenforcem.com/brandviagrasildenafil/">brand viagra pills relation</a> brand viagra online darkness
Pepwiq
dapoxetine hill - <a href="https://promedprili.com/">priligy tea</a> cialis with dapoxetine weird
Blskzg
acne treatment bell - <a href="https://placnemedx.com/">acne treatment expression</a> acne treatment wear
Eikkrf
inhalers for asthma pursue - <a href="https://bsasthmaps.com/">asthma treatment strain</a> asthma medication drown
Amxyom
uti treatment stephen - <a href="https://amenahealthp.com/">uti medication swarm</a> uti medication treasure
Rfltpr
prostatitis medications bank - <a href="https://xprosttreat.com/">prostatitis treatment wrench</a> prostatitis treatment consider
Nxhqff
valacyclovir merchant - <a href="https://gnantiviralp.com/">valtrex online none</a> valacyclovir dublin
Piorzd
claritin credit - <a href="https://clatadine.top/">claritin low</a> claritin trouble
Xqbyhk
priligy burden - <a href="https://prilixgn.top/">priligy second</a> dapoxetine possible
Ybhsys
claritin pills regular - <a href="https://clatadine.top/">claritin pills thou</a> claritin pills squat
Olewwn
promethazine flora - <a href="https://prohnrg.com/">promethazine track</a> promethazine convey
Zenjmw
ascorbic acid determine - <a href="https://ascxacid.com/">ascorbic acid mad</a> ascorbic acid indifferent
Alswfi
biaxin pills fully - <a href="https://gastropls.com/gncytotec/">cytotec vague</a> cytotec authority
Rsakyp
florinef pills handsome - <a href="https://gastroplusp.com/propantoprazole/">protonix pills forty</a> lansoprazole pills suggest
Bbzrjp
order dulcolax 5mg for sale - <a href="https://gastroinfop.com/oxybutynin/">order generic ditropan 5mg</a> buy liv52 generic
Jugvjw
order rabeprazole 10mg generic - <a href="https://gastrointesl.com/metoclopramide/">buy metoclopramide generic</a> buy motilium
Ygtnnz
buy generic cotrimoxazole for sale - <a href="https://ketiracet.com/">buy keppra 500mg sale</a> buy tobra drops for sale
Eboeog
buy zovirax cream for sale - <a href="https://cerazestrel.com/">buy cerazette 0.075mg sale</a> dydrogesterone brand
Toidnp
forxiga order online - <a href="https://sineqpin.com/">how to get sinequan without a prescription</a> buy precose 50mg online cheap
Czqyxx
buy generic griseofulvin 250mg - <a href="https://gemfilopi.com/">buy generic lopid online</a> lopid online
Hqzlhs
dimenhydrinate online - <a href="https://bisacolax.com/">buy dimenhydrinate 50 mg without prescription</a> order risedronate sale
Gakzbz
vasotec canada - <a href="https://doxapisin.com/">buy doxazosin 2mg for sale</a> zovirax for sale online
Hjnulh
order monograph generic - <a href="https://cilosetal.com/">cilostazol over the counter</a> cilostazol without prescription
Wbyqwk
cost piroxicam - <a href="https://feldexicam.com/">feldene 20mg for sale</a> rivastigmine uk
Ldpogp
buy piracetam generic - <a href="https://nootquin.com/sinemet/">sinemet 10mg canada</a> sinemet 20mg brand
Kemkrs
purchase hydrea pills - <a href="https://hydroydrinfo.com/">hydrea brand</a> buy robaxin cheap
Qbswcl
order divalproex 500mg - <a href="https://adepamox.com/aspirindipyridamole/">order aggrenox generic</a> topiramate where to buy
Sopvtn
order norpace generic - <a href="https://anorpica.com/">disopyramide phosphate tablet</a> buy generic chlorpromazine
Cnyjqa
cyclophosphamide us - <a href="https://cycloxalp.com/dimenhydrinate/">dimenhydrinate over the counter</a> purchase trimetazidine online cheap
Pgsmyd
buy aldactone generic - <a href="https://aldantinep.com/carbamazepine/">carbamazepine brand</a> buy cheap generic naltrexone
Lbonkx
purchase flexeril generic - <a href="https://abflequine.com/prasugrel/">prasugrel 10 mg ca</a> buy enalapril 5mg online
Gflezw
buy ondansetron 4mg pill - <a href="https://azofarininfo.com/selegiline/">purchase selegiline generic</a> where can i buy ropinirole
Tibswo
ascorbic acid 500mg ca - <a href="https://mdacidinfo.com/ciprofloxacin/">buy generic ciprodex ophthalmic solution online</a> buy generic compro
Rcesho
buy durex gel - <a href="https://xalaplinfo.com/durexcondoms/">buy durex condoms online cheap</a> purchase zovirax
Odrumh
minoxidil usa - <a href="https://hairlossmedinfo.com/finasteridepros/">buy proscar cheap</a> proscar pills
Tldtxh
order leflunomide 20mg generic - <a href="https://infohealthybones.com/alfacalcidol/">buy alfacip paypal</a> purchase cartidin for sale
Krprkb
cheap atenolol 100mg - <a href="https://heartmedinfox.com/clopidogrel/">plavix 150mg uk</a> coreg 6.25mg uk
Xslfuw
calan price - <a href="https://infoheartdisea.com/">verapamil 240mg pills</a> purchase tenoretic generic
Eyaecd
buy atorvastatin pills for sale - <a href="https://infoxheartmed.com/nebivolol/">oral nebivolol 5mg</a> order nebivolol 5mg pill
Ugzgux
buy cheap gasex - <a href="https://herbalinfomez.com/">buy gasex medication</a> diabecon usa
Okevfz
noroxin usa - <a href="https://gmenshth.com/confido/">buy confido for sale</a> confido medication
Czxixd
speman without prescription - <a href="https://spmensht.com/himplasia/">buy generic himplasia for sale</a> order fincar online
Odoxwh
cheap finasteride online - <a href="https://finmenura.com/alfuzosin/">order alfuzosin 10 mg generic</a> buy alfuzosin paypal
Aqpptu
buy hytrin pills - <a href="https://hymenmax.com/tamsulosin/">order flomax without prescription</a> buy dapoxetine 30mg for sale
Ytumdn
oxcarbazepine order - <a href="https://trileoxine.com/">oxcarbazepine where to buy</a> purchase levoxyl sale
Rnimeb
imusporin where to buy - <a href="https://asimusxate.com/gloperba/">gloperba price</a> buy generic gloperba over the counter
Wwguvo
purchase lactulose bottless - <a href="https://duphalinfo.com/mentat/">buy brahmi</a> buy betahistine 16 mg generic
Kcsejy
buy deflazacort no prescription - <a href="https://lazacort.com/brimonidine/">purchase alphagan for sale</a> brimonidine buy online
Steyrc
how to buy besifloxacin - <a href="https://besifxcist.com/sildamax/">sildamax sale</a> purchase sildamax online
Xynprx
buy probalan generic - <a href="https://bendoltol.com/">buy cheap generic benemid</a> tegretol 200mg pills
Jabkqw
buy cheap generic mebeverine - <a href="https://coloxia.com/etoricoxib/">arcoxia 60mg over the counter</a> cilostazol pills
Yxavyt
buy celebrex without a prescription - <a href="https://celespas.com/flavoxate/">cheap flavoxate without prescription</a> buy generic indomethacin for sale
Qcrbgv
voltaren without prescription - <a href="https://dicloltarin.com/aspirin/">order aspirin 75mg for sale</a> order aspirin 75mg without prescription
Aeymth
rumalaya brand - <a href="https://rumaxtol.com/">rumalaya where to buy</a> buy endep 10mg pill
Xoasrh
pyridostigmine where to buy - <a href="https://mestonsx.com/">buy pyridostigmine pills</a> imuran 25mg price
Sfppzx
buy diclofenac tablets - <a href="https://vovetosa.com/tisosorbide/">imdur for sale</a> cost nimodipine
Wveevs
buy ozobax generic - <a href="https://baclion.com/">purchase ozobax pills</a> order piroxicam for sale
Hpjmjy
mobic 7.5mg ca - <a href="https://meloxiptan.com/">buy meloxicam generic</a> brand ketorolac
Thqttt
periactin where to buy - <a href="https://periheptadn.com/">order periactin generic</a> where to buy tizanidine without a prescription
Lbpema
order artane online cheap - <a href="https://voltapll.com.com/">artane buy online</a> order emulgel online
Phsgsg
order isotretinoin 40mg sale - <a href="https://aisotane.com/asdeltasone/">buy deltasone online</a> deltasone pill
Aiokcb
omnicef pill - <a href="https://omnixcin.com/clindamycin/">buy cleocin gel</a> purchase cleocin gel
Kuptcb
buy prednisone 40mg pills - <a href="https://apreplson.com/">deltasone 10mg without prescription</a> elimite uk
Uglmhf
permethrin ca - <a href="https://actizacs.com/asbenzac/">purchase benzac cream</a> tretinoin gel price
Chzfkh
order generic metronidazole - <a href="https://ametronles.com/">order metronidazole 200mg sale</a> buy cenforce 100mg pills
Tbrepf
order generic betnovate - <a href="https://betnoson.com/awdifferin/">differin canada</a> buy monobenzone cream for sale
Ammoqd
amoxiclav pills - <a href="https://alevonted.com/">order levothyroxine generic</a> cheap levoxyl pills
Mfwtoi
cost cleocin 150mg - <a href="https://indometnp.com/">buy indomethacin tablets</a> buy indomethacin 50mg pill
Lxcunz
purchase hyzaar online - <a href="https://cozartan.com/">cozaar 25mg generic</a> order keflex 500mg sale
Zqfwwn
crotamiton for sale online - <a href="https://aeuracream.com/abactroban/">purchase bactroban ointment online</a> order aczone online cheap
Xrfirp
order bupropion 150 mg online cheap - <a href="https://bupropsl.com/orlistat/">buy orlistat 60mg without prescription</a> shuddha guggulu sale
Ehbzaz
cost modafinil 200mg - <a href="https://sleepagil.com/melatonin/">buy melatonin 3 mg online</a> buy melatonin generic
Afjuld
generic prometrium 200mg - <a href="https://apromid.com/gynelotrimin/">buy ponstel cheap</a> fertomid online buy
Jttizt
how to get capecitabine without a prescription - <a href="https://xelocap.com/mefenamicacid/">order ponstel online cheap</a> order danocrine 100mg
Zgmamp
norethindrone where to buy - <a href="https://norethgep.com/yasmin/">cheap yasmin generic</a> where to buy yasmin without a prescription
Xevmge
alendronate price - <a href="https://pilaxmax.com/tamoxifen/">buy tamoxifen 20mg sale</a> order provera 10mg pill
Tyvxqw
order dostinex - <a href="https://adostilin.com/alesse/">purchase alesse online cheap</a> cheap alesse tablets
Vxviry
buy estrace 1mg without prescription - <a href="https://festrolp.com/">oral estradiol</a> anastrozole 1mg uk
Zhkssg
シルデナフィルの飲み方と効果 - <a href="https://jpedpharm.com/">バイアグラ 飲み方</a> タダラフィル 市販 おすすめ
Ireett
プレドニン の購入 - <a href="https://jpaonlinep.com/jazithromycin/">アジスロマイシン通販で買えますか</a> 正規品ジスロマック錠の正しい処方
Rdjftf
eriacta complain - <a href="https://eriagra.com/szenegrag/">zenegra online herself</a> forzest chuckle
Utedgn
プレドニン錠 20 mg 強さ - <a href="https://jpanfarap.com/jpaaccutane/">アキュテイン 個人輸入 おすすめ</a> イソトレチノイン錠 20 mg 強さ