基于Python的爱加密接口调用代码实例 代码描述:基于Python的爱加密接口调用代码实例 代码平台:聚合数据 #!/usr/bin/python # -*- coding: utf-8 -*- importjson, urllib fromurllib importurlencode #---------------------------------- # APK加密调用示例代码 - 聚合数据 # 在线接口文档:http://www.juhe.cn/docs/76 #---------------------------------- defmain(): #配置您申请的APPKey appkey ="*********************" #1.①根据url上传待加密的apk request1(appkey,"GET") #2.②提交加密应用加密 request2(appkey,"GET") #3.③查询加密结果 request3(appkey,"GET") #①根据url上传待加密的apk defrequest1(appkey, m="GET"): url ="http://op.juhe.cn/ijiami/upload" params ={ "apkurl": "", #需要进行加密的APK下载URL地址 "key": appkey, #应用APPKEY(应用详细页查询) "dtype": "", #返回数据的格式,xml或json,默认json } params =urlencode(params) ifm =="GET": f =urllib.urlopen("%s?%s"%(url, params)) else: f =urllib.urlopen(url, params) content =f.read() res =json.loads(content) ifres: error_code =res["error_code"] iferror_code ==0: #成功请求 printres["result"] else: print"%s:%s"%(res["error_code"],res["reason"]) else: print"request api error" #②提交加密应用加密 defrequest2(appkey, m="GET"): url ="http://op.juhe.cn/ijiami/encrypt" params ={ "appid": "", #步骤①返回的appid "key": appkey, #应用APPKEY(应用详细页查询) "dtype": "", #返回数据的格式,xml或json,默认json } params =urlencode(params) ifm =="GET": f =urllib.urlopen("%s?%s"%(url, params)) else: f =urllib.urlopen(url, params) content =f.read() res =json.loads(content) ifres: error_code =res["error_code"] iferror_code ==0: #成功请求 printres["result"] else: print"%s:%s"%(res["error_code"],res["reason"]) else: print"request api error" #③查询加密结果 defrequest3(appkey, m="GET"): url ="http://op.juhe.cn/ijiami/result" params ={ "appid": "", #步骤②返回的appid "key": appkey, #应用APPKEY(应用详细页查询) "dtype": "", #返回数据的格式,xml或json,默认json } params =urlencode(params) ifm =="GET": f =urllib.urlopen("%s?%s"%(url, params)) else: f =urllib.urlopen(url, params) content =f.read() res =json.loads(content) ifres: error_code =res["error_code"] iferror_code ==0: #成功请求 printres["result"] else: print"%s:%s"%(res["error_code"],res["reason"]) else: print"request api error" if__name__ =='__main__': main() 本文来源:https://www.wddqw.com/doc/1c48329cf7ec4afe05a1df58.html