腾讯后台对接接口案例

不管前端后端涉及到三方平台都需要对接三方平台。按照文档一步一步操作。往往可以解决问题。中途也会几经波折。只有处理过的这类工作的人才深有体会。所以才衍生出 易接sdk 这类公司。这里提供思路。三方集成sdk(成熟,全面)-> 平台强硬要求自己的对接。所以技术在手,靠自己丰衣足食。这里给撸一段腾讯的对接接口。至少自己以后可以回顾自己。如果对你有帮助我也很替你开心。

# -*- coding: utf-8 -*-
# chenxiaoyumail@gmail.com
# 腾讯对接细节案例
# 主流web 接口 md5(使用key + context + 时间戳) 或 类md5 非加密
# 代码可以运行 由于商业已经把key appid id 给弄掉了。直接套用自己的即可使用

import os,sys
import urllib2
import hashlib
import time

def md5hex(word):
    """ MD5加密算法,返回32位小写16进制符号 """ 
    if isinstance(word, unicode): 
        word = word.encode("utf-8") 
    elif not isinstance(word, str): 
        word = str(word) 
    m = hashlib.md5() 
    m.update(word) 
    return m.hexdigest()


#文档网址
#http://wiki.open.qq.com/wiki/YSDK%E5%90%8E%E5%8F%B0%E6%8E%A5%E5%8F%A3

t = int(time.time())

reqhttp = 'http://ysdktest.qq.com/auth/qq_check_token?'
appid='appid'
openid='openid'
openkey='openkey'
AppKey='AppKey'

sig=md5hex(AppKey+str(t))

url = reqhttp + 'timestamp={}&appid={}&sig={}&openid={}&openkey={}'.format(str(t),appid,sig,openid,openkey) 
req = urllib2.Request(url) # url 转换成发起get 请求的url  
result = urllib2.urlopen(req) # 发起GET http服务  
res = result.read() #把结果通过.read()函数读取出来
print "AppKey",AppKey
print url
print res


'''
openid=''
openkey=''

reqhttp = 'http://ysdktest.qq.com/auth/wx_check_token?'
appid='appid'
wxAppKey='wxAppKey'
sig=md5hex(wxAppKey+str(t))
url = reqhttp + 'timestamp={}&appid={}&sig={}&openid={}&openkey={}'.format(str(t),appid,sig,openid,openkey) 
req = urllib2.Request(url) # url 转换成发起get 请求的url  
result = urllib2.urlopen(req) # 发起GET http服务  
res = result.read() #把结果通过.read()函数读取出来
print "AppKey",wxAppKey
print url
print res
'''

运行结果.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 从事移动广告商业变现多年,总是觉得产品与商务的同事是一对“欢喜冤家”。站在开发者的角度,关注用户体验最优是无可厚非...
    游社长阅读 8,722评论 2 78
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,251评论 4 61
  • 什么都不做该多好 躺着 思考着 无聊着 无为着 我想丢掉那些孤独寂寞 忘了忧伤 抛掉爱 自己生活在自己的世界里 与...
    欣欣棒棒糖阅读 376评论 1 1
  • 想着今天一定要早睡,17:00打开电脑写简书。东翻西看,时间像条小泥鳅滑溜而过。 小伙伴见我有时熬夜,要我两天写一...
    知了唯知爱阅读 331评论 0 0
  • 科研终于有进步了!!!普天同庆
    阳光半沐阅读 129评论 1 0