-
Notifications
You must be signed in to change notification settings - Fork 17
阿里云API市场
liuyuancheng edited this page Mar 4, 2018
·
6 revisions
目前,入驻云市场的千余家优秀ISV遍布国内外,提供围绕云计算产品的软件应用及服务,包括基础软件、服务、安全、企业应用、建站、解决方案及数据八大类市场,商品数量达数千种。
其中包含了海量的API资源,提供丰富的数据服务。
※ 云市场官网
AppCode阿里云API市场的简单授权方法,参考"使用 AppCode 调用"官方文档。在云市场购买API之后,云市场已购买的服务中能看到AppCode:
-
翻译插件
# -*- coding: utf-8-*- import logging, json from src.plugins import is_all_word_segment_in_text import requests, sys from src.config import load_yaml_settings WORDS = ["用英文怎么说", "用英语怎么说", "翻译一下", "翻译"] PRIORITY = 11 logger = logging.getLogger() def handle(text, mic, profile, iot_client=None,chatbot=None): text = ''.join(text) text = text.replace('翻译一下', '', 1) text =text.replace('翻译', '', 1) text =text.replace('用英语怎么说', '', 1) text =text.replace('用英文怎么说', '', 1) host = 'http://jisuzxfy.market.alicloudapi.com' path = '/translate/translate' method = 'GET' appcode = load_yaml_settings()['aliyun']['api_market']['appcode'] querys = 'from=zh-CN&text=' + text + '&to=en&type=google' bodys = {} url = host + path + '?' + querys headers = { 'Authorization': 'APPCODE ' + appcode, 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' } r = requests.request(method=method, url=url, data=bodys, headers=headers) data = json.loads(r.content.decode('utf8')) if int(data['status']) == 0: mic.say(data['result']['result']) else: mic.say('阿里云接口调用出错,检查一下插件吧') def is_valid(text): return is_all_word_segment_in_text(WORDS, text)
-
天气预报
# -*- coding: utf-8-*- import logging, json from src.plugins import is_all_word_segment_in_text, plugin_output import requests, sys from src.config import load_yaml_settings WORDS = ['新闻', '今日头条'] PRIORITY = 12 logger = logging.getLogger() def handle(text, mic, profile, iot_client=None,chatbot=None): host = 'http://toutiao-ali.juheapi.com' path = '/toutiao/index' method = 'GET' appcode = load_yaml_settings()['aliyun']['api_market']['appcode'] querys = 'type=top' bodys = {} url = host + path + '?' + querys headers = { 'Authorization': 'APPCODE ' + appcode, 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' } r = requests.request(method=method, url=url, data=bodys, headers=headers) data = json.loads(r.content.decode('utf8')) # print(data) if data['result']['stat'] == '1': # print(data) news = [] news_ding = [] for item in data['result']['data']: news.append(item['title']) news_ding.append('['+item['title']+']('+item['url']+') ') plugin_output(text, mic, robot_says='。\n'.join(news), force_ding=True, ding_content=' | '.join(news_ding)) else: mic.say('接口出错') def is_valid(text): return is_all_word_segment_in_text(WORDS, text)
Kim,一个完整的智能家居方案。
介绍
安装配置
插件开发
附录