dengyg200891
# -*- coding: cp936 -*-
#python 27
#xiaodeng



#获取微信access_token
#办法一:将该url直接填写到浏览器地址中可以获得access_token
url=\'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxc0f4d0ed1cb2f4e1&secret=c4d72d33cacf8c94845ac906ad60eed6\'


#办法二
import urllib
url=\'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential\'#grant_type为固定值
data={\'appid\':\'wxc0f4d0ed1cb2f4e1\',
      \'secret\':\'c4d72d33cacf8c94845ac906ad60eed6\'}

data=urllib.urlencode(data)
html=urllib.urlopen(url,data)#<addinfourl at 34758208 whose fp = <socket._fileobject object at 0x0212F570>>
html= html.read()
print html
\'\'\'
{"access_token":"Isd_tm3QE8Kateyxjz_WEEXuerBZ0gnO6XwyjirZXY1umVIDqebi6GK2Zv2fv1hI7sXQfHXeaOa2A4XrOITwS5LnczFRXf4BbSnMdSRLKiwBQYgADASHP",
"expires_in":7200}  #expires_in,定义access_token有效时间,单位为秒
\'\'\'

 

分类:

技术点:

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-11-20
  • 2021-12-04
  • 2022-02-06
  • 2021-12-25
  • 2022-12-23
  • 2021-05-04
猜你喜欢
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-12-14
  • 2021-05-28
相关资源
相似解决方案