LaneWeChat

PHP微信开发框架,高效开发微信公众号应用。简洁而又轻量

GitHub下载 查看手册

AccessToken授权

Visits: 22711 Date: 2014-08-20 17:26:58 Power By 李轩Lane

    

1、类简介:除了被动相应用户之外,在主动给用户发送消息,用户组管理等高级操作,是需要AccessToken授权的,我们调用一个URL给微信服务器,微信服务器会返回给我们一个散列字符串,在高级操作的时候需要将此串以参数的形式发送。散列字符串10分钟内有效,过期需要重新获取,获取新的后之前的全部失效。


        2、使用命名空间:use LaneWeChat\Core\AccessToken;


        3、参数:无


        4、获取AccessToken

            AccessToken::getAccessToken(); 该调用会返回微信服务器散列后的AccessToken字符串。


        5、温馨提示


            如果暂且用不到此功能,请跳过。最后来看这里!


        6、功能补充

            有一个地方需要用户自行完善,根据介绍我们已经知道了,获取AccessToken只有10分钟的有效期,过期需要重新获取。因此,我们需要存储这个AccessToken。

            由于大家的存储方式各不相同,有Mysql的,有Redis的,有MongoDB的,还有Session的。所以这里我讲存储和读取给留空了。

            流程:AccessToken类,public方法只有一个,就是getAccessToken()。这个方法会调用一个私有方法_checkAccessToken()来检测AccessToken是否存在并且是否过期,如果不存在或过期,则调用私有方法_getAccessToken()

            完善步骤:

            1)、打开core/accesstoken.lib.php文件。

            2)、私有方法_getAccessToken()的倒数第二行(return是倒数第一行),在这个地方,请讲变量$accessTokenJson存储起来,变量$accessTokenJson是一个字符串。

            3)、私有方法_checkAccessToken()的第一行就是读取操作(有一行伪代码$accessToken = YourDatabase::get('access_token');),将刚才第二步的存储的东西给读出来,并且赋值给$accessToken。

            4)、在第二步的存储,第三部的读取的时候,请不要修改数据,仅仅完善一个读和存的操作就可以了。


Reply: yxs On 2014-12-08 09:27:50

现在 AccessToken 的 有效期 增加为了 7200

回复

Reply: izhi On 2015-06-18 22:57:58

请问$accessToken = YourDatabase::get('access_token');这局是把YourDatabase换成是自己的数据库名吗?我用的SAE,替换之后显示错误。Fatal error: Class 'LaneWeChat\Core\SAE_MYSQL_DB' not found in core/accesstoken.lib.php on line 58。

回复

Reply: zokio On 2015-09-08 01:05:46

一头雾水,请问上面这些代码要写在哪个文件里面?小白问题,请见谅。

回复

Reply: eden_cola On 2016-01-08 17:43:52

目前的最新版本中,缓存accessToken的文件使用的是相对路径,这在同时存在多个不同目录下的入口文件时会产生冲突,比如尝试将LaneWechat引入到ThinkPhp的项目中使用时,thinkphp的index.php经常和LaneWechat的wechat.php不在同一目录

回复

Reply: eden_cola On 2016-01-08 17:51:41

我是新程序员……不是很清楚该怎么反馈问题,我这次的解决方法是在config.php中添加了一个新的配置项,设定一个固定的缓存目录

回复

Reply: fu On 2016-03-29 10:28:23

session 无法使用

回复

Reply: mengrulsy On 2016-04-25 18:35:29

相应-->响应; 排版体验不好哦

回复

Reply: yuli On 2017-02-06 01:15:49

如果申请了微信第三方平台,access_token获取方式不一样,已经另外写代码实现。 也就是说不依赖框架获取access_token,这块代码怎么处理。

回复

Reply: gapeepict On 2020-06-15 08:18:06

Interigo Keflex https://agenericcialise.com/ - Generic Cialis Effet Cytotec Contraception <a href=https://agenericcialise.com/#>cialis generic timeline</a> Cyotec Oregon

回复

Reply: gapeepict On 2020-06-16 09:57:40

Cialis Vendita Pillole https://cheapcialisll.com/ - Cheap Cialis cialis why the bathtubs <a href=https://cheapcialisll.com/#>Cialis</a> Propecia For Hair Care

回复

Reply: cialis online On 2020-07-06 04:18:45

Preise Levitra Lelefuerse https://ascialis.com/# - when will cialis be generic tumjuptImpam Precio De Priligy irralymN <a href=https://ascialis.com/#>Cialis</a> goormapoge Discount Doxycycline Buy

回复

Reply: generic cialis On 2020-07-17 20:32:48

Comprar Cialis Foro Barato Payolatt https://bbuycialisss.com/# - Cialis acipittete Cialis 20mg Tadalafil Achat chaccincicic <a href=https://bbuycialisss.com/#>Buy Cialis</a> PupHeets buy accutane online cheap

回复

Reply: buy cialis 10mg On 2020-08-31 12:17:42

Adverse Reations To Amoxicillin Lelefuerse https://cialiser.com/ - Cialis tumjuptImpam Can Collies Take Keflex And Tramadol irralymN <a href=https://cialiser.com/#>Cialis</a> goormapoge Propecia Dosage 5mg

回复

Reply: Dwain On 2020-10-30 20:15:19

To complicate matters, older adults are at higher risk for side effects from antidepressants, such as increased danger of falling and loss of bone density, as well as drug interactions with their other meds. viagra in india sildenafil vs viagra

回复

Reply: Jildcisona On 2020-11-07 08:37:11

buy viagra online reviews http://fmedrx.com/ <a href="http://fmedrx.com/#">100mg generic viagra</a> generic viagra online

回复

Reply: Kmrfisona On 2020-11-10 12:40:50

cheap viagra online pharmacy http://usggrxmed.com/ <a href="http://usggrxmed.com/#">marley generic viagra</a> viagra online cheap

回复

Reply: Fevbisona On 2020-11-16 10:15:33

viagra suppliers online <a href="https://wowviaprice.com/#">walmart viagra cost</a> generic viagra 100mg sildenafil

回复

Reply: Fevbisona On 2020-11-16 10:27:15

where can i order viagra super forse <a href="https://wowviaprice.com/#">https://wowviaprice.com/</a> viagra phamacy stores in ohio

回复

Reply: JivhApery On 2020-11-17 02:34:05

what gives the same effect as viagra <a href="https://purevigra.com/#">radio ads for viagra</a> men viagra videos

回复

Reply: Fbsgisona On 2020-11-19 04:00:56

viagra somministrato alle donne <a href="https://buybuyviamen.com/#">what happens if you take half a viagra pill</a> sou jovem posso tomar viagra

回复

Reply: FrbhAlado On 2020-11-19 08:04:51

generic viagras <a href="https://paradiseviagira.com/#">paradiseviagira.com</a> genic viagra

回复

Reply: DevkAlado On 2020-11-19 15:39:39

newest viagra <a href="https://paradiseviagira.com/#">viagra pro online</a> viagra pill

回复

Reply: Fhsbisona On 2020-11-21 01:07:05

comment reconnaitre vrai viagra <a href="https://buybuyviamen.com/#">buybuyviamen.com</a> qual diferença entre viagra e cialis

回复

Reply: Kbrgprot On 2020-11-21 05:38:00

where to get female viagra nz <a href="https://miraclevigra.com/#">viagra tablets for sale uk</a> buy usa viagra online

回复

Reply: JsweApery On 2020-11-25 00:19:30

viagra cost in canada <a href="https://mygoviagar.com/#">cheap canadian pharmacy viagra</a> sildenafil generic 50 mg

回复

Reply: Fnrhisona On 2020-11-25 05:14:00

where do you buy viagra in melbourne <a href="https://genqpviag.com/#">generic viagra</a> viagra without prescription

回复

Reply: Fnrdisona On 2020-11-25 05:15:07

i want to buy viagra online <a href="https://llviabest.com/#">viagra without a script</a> brand viagra overnight

回复

Reply: Fmsgisona On 2020-11-27 04:21:33

how to tell if viagra is genuine <a href="https://siviagmen.com/#">100mg viagra wiki</a> viagra generico normon

回复

Reply: FdbvAlado On 2020-11-27 05:07:46

viagra 100mg tablet price in india <a href="https://hopeviagrin.com/#">viagra gel for sale</a> generic viagra without prescription

回复

Reply: DbsfAlado On 2020-11-27 12:46:25

how much is female viagra pill <a href="https://lightvigra.com/#">buy viagra online 100mg</a> viagra from mexico to us

回复

Reply: Fbsbisona On 2020-11-28 20:12:46

viagra in sheffield <a href="https://genericrxxx.com/#">side effects from generic viagra</a> viagra en ayunas

回复

Reply: Kwgdprot On 2020-11-29 06:43:10

write my paper for me cheap <a href="https://researchpaperssfk.com/#">best homework college online help</a> case study 4

回复

Reply: Ftghisona On 2020-11-29 10:59:52

write my dissertation uk <a href="https://thesiswritinghelpsjj.com/#">a research paper</a> help on homework math

回复

Reply: JgscApery On 2020-11-30 05:19:35

photo essay assignment <a href="https://thesisbyd.com/#">coursework writing service</a> writing a case study essay

回复

Reply: Fsfisona On 2020-11-30 17:46:46

help my essay <a href="https://essayhelpbgs.com/#">scientific subjects for research papers</a> essay with thesis statement

回复

Reply: Fnsbisona On 2020-12-02 23:39:25

buy assignments uk <a href="https://customessaywriterbyz.com/#">assignments help</a> writing a narrative essay for dummies

回复

Reply: Fgrsisona On 2020-12-10 13:06:09

super force viagra <a href="https://xviagrnorx.com/#">viagra premature ejaculation treatment</a> viagra sydney genuine

回复

Reply: Khedprot On 2020-12-10 17:12:39

viagra canada overnight <a href="https://buyviagrrxon.com/#">buy viagra on line?</a> is it illegal to buy viagra online

回复

Reply: Fqbfisona On 2020-12-11 06:10:21

free cialis in canada <a href="https://gocialirx.com/#">ebay cialis</a> cialis 10mg generic

回复

Reply: Fsfgisona On 2020-12-11 17:07:22

viagra in portland <a href="https://viagstorerx.com/#">viagra cheap master card</a> buy viagra onlie

回复

Reply: JgsvApery On 2020-12-11 17:35:20

viagra surgery <a href="https://atviagrmenrx.com/#">viagras head office in toronto</a> google news cheap viagra

回复

Reply: FgnsAlado On 2020-12-12 02:24:50

cialis online america <a href="https://tadafcialirx.com/#">cialis substitutes</a> cialis us pharmacy

回复

Reply: Fbsbisona On 2020-12-12 05:32:16

cialis using paypal <a href="https://cialmenon.com/#">cialis hk</a> where can i get cialis overnite

回复

Reply: DvncAlado On 2020-12-12 09:31:21

cialis online paypal <a href="https://vipmenciall.com/#">cheapest cialis 5mg</a> cialis and dapoxetime tabs in usa

回复

Reply: FhsnAlado On 2020-12-17 01:20:34

viagra super overnight <a href="https://lightvigra.com/#">sex shoping viagra</a> viagra buy usa

回复

Reply: DvnjAlado On 2020-12-17 08:39:31

viagra, cialis levitra online <a href="https://hopeviagrin.com/#">viagra dapoxetine canada</a> alternatives to viagra

回复

Reply: FgvdAlado On 2021-01-10 02:00:39

canadian pharmacy online <a href="http://canadapharmacyonlinestbh.com/#">longs drug store</a> best drugstore bronzer

回复

Reply: JlloApery On 2021-01-13 07:32:24

medical pharmacy <a href="http://canadianonline-pharmacydazc.com/#">us online pharmacy</a> п»їviagra online canadian pharmacy

回复

Reply: FgnhAlado On 2021-01-14 06:19:46

viagra price in india <a href="http://ltdviagragogo.com/#">il viagra in uk</a> legitimate viagra viagra walmart farmacv <a href="http://hdgenericviagraxk.com/#">viagra for sale melbourne</a> viagra time of action buy viagra with dapoxetine <a href="http://buygenericviarga.com/#">buy female viagra online</a> generic viagra discover order cheap viagra online without prescription overnight shipping available <a href="http://buyhdpillvia.com/#">paypal to buy viagra</a> cheap viagra in usa generic viagra chewable <a href="http://genericviagrix.com/#">50mg viagra</a> buy viagra online no prescription

回复

Reply: JvcxApery On 2021-01-17 07:25:24

generic viagra <a href="http://fmedrx.com/#">trusted store viagra generic</a> viagra free trial offer what to say to get prescribed viagra <a href="http://edabcrx.com/#">viagra without prescription canada</a> melbourne buy viagra sign up viagra <a href="http://abcrxmed.com/#">viagra posted</a> viagra mastercard taking viagra with irregular heartbeat <a href="http://cialedrx.com/#">cialis and viagra taken together</a> buy viagra in canada toronto 100mg viagra for sale <a href="http://hitrxmenvia.com/#">viagraonline\\</a> buy viagra, pay mastercard

回复

Reply: NlbxAlado On 2021-01-18 00:41:03

cheap viagra <a href="http://viashoprx.com/#">buying viagra in ireland</a> viagra samples free online viagra dosage women <a href="http://xviagarrx.com/#">viagra super force</a> viagra generisches viagra paypal <a href="http://viagraviagria.com/#">penis pump viagra</a> free viagra online without prescription walmart pharmacy online viagra <a href="http://asgenviagria.com/#">cheap generic viagra</a> viagra on line legitimate viagra suppliers <a href="http://viagengen.com/#">viagra 100 mg price</a> where to buy plizer 100mg viagra

回复

Add Comment
©2014 lanewechat.lanecn.com , All rights reserved. Power By LaneWeChat 微信PHP开发框架.  京ICP备14005030号-1