# -*- coding: utf-8 -*- from base64 import b64encode from base import BaseService from app.model import Device if __name__ == '__main__': import sys sys.path.insert(0, '../..') from app.config import CONF, DBSession KEY = CONF.get('luosimao', 'key') class LuoSiMao(BaseService): method = 'post' url = 'https://sms-api.luosimao.com' base = '/v1' key = KEY session = DBSession def gen_request(self): self.headers['Authorization'] = 'Basic ' + b64encode( 'api:key-%s' % self.key) return super(LuoSiMao, self).gen_request() def send(self, to, data): self.path = '/send.json' self.p = { 'mobile': to, 'message': u'尊敬的用户:您的校验码:%s,工作人员不会索取,请勿泄露。【思科德】' % data,
# -*- coding: utf-8 -*- from base import BaseService from tornado.escape import json_encode from app.model import Device from tornado.httpclient import HTTPClient, HTTPRequest, AsyncHTTPClient if __name__ == '__main__': import sys sys.path.insert(0, '../..') from app.config import CONF, DBSession APP_KEY = CONF.get('jiguang', 'appkey') SECRET = CONF.get('jiguang', 'secret') class JiguangService(BaseService): url = 'https://api.jpush.cn' base = '/v3' session = DBSession def gen_request(self): s = '{}:{}'.format(APP_KEY, SECRET) self.headers['Authorization'] = 'Basic {}'.format( s.encode('base64').strip()) if not self.raw: return super(JiguangService, self).gen_request() url = '%s%s%s' % (self.url, self.base, self.path)
# -*- coding: UTF-8 -*- if __name__ == '__main__': import sys sys.path.insert(0, '../..') from app.config import CONF URL = CONF.get('agent', 'url') + '/aliot' FTPURL = CONF.get('agent', 'url') from base import BaseService class ALiProductService(BaseService): method = 'post' url = URL base = '/product' def create(self, name): self.path = '/create' self.p = { 'name': name, } return self def update(self, productkey, productname, productdesc): self.path = '/update' self.p = { 'productkey': productkey, 'productname': productname,