class WeiXin(object): def __init__(self, corpid, secrect, agentid, touser, product, toparty): self.agentid = agentid self.touser = touser self.toparty = toparty self.product = product self.api = CorpApi(corpid, secrect) def send(self, msg): msg = self.product + ":\r\n" + msg try: response = self.api.httpCall( CORP_API_TYPE['MESSAGE_SEND'], { "touser": self.touser, "toparty": self.toparty, "agentid": self.agentid, 'msgtype': 'text', #'climsgid' : 'climsgidclimsgid_%f' % (random.random()), 'text': { 'content': msg, }, 'safe': 0, }) print('发送成功', response) except ApiException as e: print(e.errCode, e.errMsg)
def __init__(self, corpid, secrect, agentid, touser, product, toparty): self.agentid = agentid self.touser = touser self.toparty = toparty self.product = product self.api = CorpApi(corpid, secrect)
import sys import random sys.path.append("../src/") from api.src.CorpApi import * from api.examples.TestConf import * from api.src.AbstractApi import ApiException api = CorpApi(TestConf['CORP_ID'], TestConf['APP_SECRET']) try: response = api.httpCall( CORP_API_TYPE['MESSAGE_SEND'], { "touser": "******", "agentid": 1000002, 'msgtype': 'text', 'climsgid': 'climsgidclimsgid_%f' % (random.random()), 'text': { 'content': '方法论', }, 'safe': 0, }) print(response) except ApiException as e: print(e.errCode, e.errMsg)
import sys sys.path.append("../src/") from api.src.CorpApi import * from api.src.AbstractApi import * from api.examples.TestConf import * api = CorpApi(TestConf['CORP_ID'], TestConf['CONTACT_SYNC_SECRET']) try: # response = api.httpCall( # CORP_API_TYPE['USER_CREATE'], # { # "userid": "apiceshi", # "name": "api测试", # "alias": "randolph", # "mobile": "13970970002", # "department": [1], # "order": [2], # "position": "技术", # "gender": "1", # "email": "*****@*****.**", # "is_leader_in_dept": [0], # 是不是部门领导 # "enable": 1, # "avatar_mediaid": "", # 上传头像的id,默认空 # "telephone": "020-123456", # "address": "上海市青浦区豪车汇10F", # "main_department": 1, # "to_invite": "", # 默认邀请 # "external_position": "技术顾问", # })
import sys import random sys.path.append("../src/") from api.src.CorpApi import * from api.examples.TestConf import * from api.src.AbstractApi import ApiException api = CorpApi(TestConf['CORP_ID'], TestConf['APP_SECRET']) try: response = api.httpCall( CORP_API_TYPE['MINIPROGRAM_CODE_TO_SESSION_KEY'], { "js_code": "sVqtL3itg0L30LTGJtZ_isKC0efG5FqGw470fVp8Dpw", "grant_type": "authorization_code" }) print(response) except ApiException as e: print(e.errCode, e.errMsg)
# @Author abelzhu, [email protected] # @Version 1.0 # @Date 2018-02-24 # # import sys sys.path.append("../src/") import random from api.src.CorpApi import * from api.examples.TestConf import * ## test api = CorpApi(TestConf['CORP_ID'], TestConf['APP_SECRET']) chatid = "test210" try: ## response = api.httpCall( CORP_API_TYPE['APP_CHAT_CREATE'], { 'name': 'appchat_test', 'owner': 'ZhuBiaoYi', 'userlist': [ 'LiShuang', 'ZhuShengBen', 'LinJianEn', 'ZhuBiaoYi', 'XuBin', 'yangpeiyi', 'HaLuoTeQu', 'lucky', 'raindong', 'simon', 'Wang', 'ZhaoDong', 'DengLinSheng', 'Li' ],
# @File UserTest.py # @Brief # @Author abelzhu, [email protected] # @Version 1.0 # @Date 2018-02-24 # # import sys sys.path.append("../src/") from api.src.CorpApi import * from api.examples.TestConf import * ## test api = CorpApi(TestConf['CORP_ID'], TestConf['CONTACT_SYNC_SECRET']) try: ## response = api.httpCall( CORP_API_TYPE['USER_CREATE'], { 'userid': 'zhangsan', 'name': 'zhangsanfeng', 'mobile': '131488888888', 'email': '*****@*****.**', 'department': 1, }) print(response) ## response = api.httpCall(CORP_API_TYPE['USER_GET'], {