记录我常用的免费API接口

目录

1.随机中英文句子

2.随机中英文句子(带图片和音频)

3.随机一句诗

4.随机一句话

5.随机一句情话

6. 随机一句舔狗语录

7.历史上的今天

8.获取来访者ip地址

9:获取手机号信息

10. 垃圾分类查询

11.字典查询

12.QQ信息查询


1.随机中英文句子

 API地址:https://api.kekc.cn/api/yien

Axios的get请求调用方式

  methods:{
        getit(){
        axios.get('https://api.kekc.cn/api/yien', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data.cn);
            this.cn = response.data.cn;
            this.en = response.data.en;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:


2.随机中英文句子(带图片和音频)

API地址:https://api.oioweb.cn/api/common/OneDayEnglish

 Axios的get请求调用方式

  methods:{
        getit(){
        axios.get('https://api.oioweb.cn/api/common/OneDayEnglish', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.cn = response.data.result.note;
            this.en = response.data.result.content;
            this.imgurl = response.data.result.img;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:


3.随机一句诗

API地址:https://v1.jinrishici.com/rensheng.txt

Axios的get请求调用方式

  methods:{
        getit(){
        axios.get('https://v1.jinrishici.com/rensheng.txt', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.cn = response.data;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:


4.随机一句话

API地址:

https://api.kekc.cn/api/yiyan

https://api.kekc.cn/api/wawr

Axios的get请求调用方式

  methods:{
        getit(){
        axios.get('https://api.kekc.cn/api/yiyan', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.cn = response.data;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:


5.随机一句情话

API地址:https://api.uomg.com/api/rand.qinghua

Axios的get请求调用方式

  methods:{
        getit(){
        axios.get('https://api.uomg.com/api/rand.qinghua', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.cn = response.data.content;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:


6. 随机一句舔狗语录

API地址:http://api.kekc.cn/api/tiangou

Axios的get请求调用方式

  methods:{
        getit(){
        axios.get('http://api.kekc.cn/api/tiangou', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.cn = response.data;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:


7.历史上的今天

API地址:https://api.oioweb.cn/api/common/history

Axios的get请求调用方式(需要注意的是会生成数组,此处仅使用了第一个元素)

  methods:{
        getit(){
        axios.get('https://api.oioweb.cn/api/common/history', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.year = response.data.result[0].year;
            this.title = response.data.result[0].title;
            this.link = response.data.result[0].link;
            this.desc = response.data.result[0].desc;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

 获取结果示例:


8.获取来访者ip地址

API地址:https://api.kekc.cn/api/getip

Axios的get请求调用方式

  methods:{
        getit(){
        axios.get('http://api.kekc.cn/api/getip', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.ipadd = response.data;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:

 


9:获取手机号信息

API地址:https://api.oioweb.cn/api/common/teladress?mobile=10086

Axios的get请求调用方式(需要注意的是该api需要后缀11位手机号作为参数)

  methods:{
        getit(){
        axios.get('https://api.oioweb.cn/api/common/teladress?mobile=15990000000', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.prov = response.data.result.prov;
            this.city = response.data.result.city;
            this.name = response.data.result.name;
            this.postcode = response.data.result.postCode;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

获取结果示例:


10. 垃圾分类查询

API地址:https://api.oioweb.cn/api/common/rubbish?name=香蕉

Axios的get请求调用方式(需要注意的是该api需要后缀要查询的垃圾名称作为参数)

  methods:{
        getit(){
        axios.get('https://api.oioweb.cn/api/common/rubbish?name=香蕉', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.contain = response.data.result[0].contain;
            this.explain = response.data.result[0].explain;
            this.name = response.data.result[0].name;
            this.tip = response.data.result[0].tip;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

 获取结果示例:


11.字典查询

API地址:https://api.oioweb.cn/api/txt/dict?text=棒

 Axios的get请求调用方式(需要注意的是该api需要后缀要查询的字作为参数)

  methods:{
        getit(){
        axios.get('https://api.oioweb.cn/api/txt/dict?text=棒', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.pinyin = response.data.result.pinyin;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

需要注意的是get到的结果中包含了基础释义和详细释义,可视情况获取,本例中只取用拼音

 获取结果示例:


12.QQ信息查询

APD地址:https://api.oioweb.cn/api/qq/info?qq=12345

 Axios的get请求调用方式(需要注意的是该api需要后缀要查询的QQ号作为参数)

  methods:{
        getit(){
        axios.get('https://api.oioweb.cn/api/qq/info?qq=12345', {
            params: {
                // 请求参数
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.age = response.data.result.age;
            this.nickname = response.data.result.nickname;
            this.sex = response.data.result.sex;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

 获取结果示例:


补充:

在需要参数的API中可以使用params传递参数,例如12中可以在页面中添加输入框,再在js中拿到输入框的值并传递给axios请求地址中获取结果:

    <input type="text" id="qqInput">
    <button @click="getit()">发送请求</button>


      methods:{
        getit(){
        var qq = document.getElementById('qqInput').value;
        axios.get('https://api.oioweb.cn/api/qq/info', {
            params: {
                // 请求参数
                qq:qq
                }
            })
            .then( (response)=> {
            // 请求成功回调函数
            console.log(response.data);
            this.age = response.data.result.age;
            this.nickname = response.data.result.nickname;
            this.sex = response.data.result.sex;
            })
            .catch(function (error) {
            //请求失败回调函数
            console.log(error);
        });
    },
  }

 获取结果示例:


未完待续... (侵删)

  • 6
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java EE常用框架 WebService 介绍 基于Web的服务。它使用Web(HTTP)方式,接收和响应外部系统的某种请求。从而实现远程调用 术语 XML. Extensible Markup Language -扩展性标记语言 WSDL – WebService Description Language – Web服务描述语言。 SOAP-Simple Object Access Protocol(简单对象访问协议) SOA(Service-Oriented Architecture) :面向服务的架构 它是一种思想,IBM大力倡导是即插即用的,IBM大力提倡,希望以组装电脑的方式来开发应用 它是目录服务,通过该服务可以注册和发布webservcie,以便第三方的调用者统一调用 使用: 二、我们可以使用Java自带的WsImport来实现本地代理。这种方法会将WebService翻译成Java类,我们使用类一样去访问WebService就行了。非常好用。 三、除了调用别人发布的webService,也可以自己发布WebService服务 四、CXF框架可以与spring无缝连接,就不用我们自己Endpoint了。它还能记录日志之类的 五、我们还可以使用Idea下的webservice,能够使用图形画面的方式获取本地代理和生成WSDL文件。 Activiti 介绍 Activiti5是一个业务流程管理(BPM)框架 如果我们的业务是比较复杂的话,我们才会用到工作流! 使用Activiti的步骤 定义工作流 画一个BPMN图就可以了 部署工作流 执行工作流-->按照我们定义的工作流来执行 工作流在执行的过程中肯定会涉及到很多数据,Activiti是默认提供数据库表给我们使用的 Activiti工作流框架快速入门: 定义工作流,使用插件来把我们的流程图画出来。这个流程图就是我们定义的工作流。 工作流引擎是工作流的核心,能够让我们定义出来的工作流部署起来。 由于我们使用工作流的时候是有很多数据产生的,因此Activiti是将数据保存到数据库表中的。这些数据库表由Actitviti创建,由Activiti维护。 部署完的工作流是需要手动去执行该工作流的。 根据由谁处理当前任务,我们就可以查询出具体的任务信息。 根据任务的id,我们就可以执行任务了。 细节 流程定义:涉及到了四张数据库表 我们可以通过API把我们的流程定义图读取出来 可以根据查询最新版本的流程定义 删除流程定义 部署流程定义的时候也可以是ZIP文件 流程运行:涉及到两个对象,四张数据库表: 流程实例 获取流程实例和任务的历史信息 判断流程实例是否为空来判断流程是否结束了 查看正在运行服务的详细信息 通过流程实例来开启流程 流程变量:它涉及到了两张表。 流 程变量实际上就是我们的条件。 作用 我们可以在流程开始的时候设置流程变量,在任务完成的时候设置流程变量。 运行时服务和流程任务都可以设置流程变量。 连线 通过连线我们可以在其中设置条件,根据不同的条件流程走不同的分支 排他网关 SpringData JPA 简介 API Repository接口 PagingAndSortingRepository JpaRepository JpaSpecificationExecutor 过滤条件查询接口 注解 nameQuery注解 SQL命名,调用的时候根据名称调用 查询注解 1,targetEntity 属性表示默认关联的实体类型,默认为当前标注的实体类。 2,cascade属性表示与此实体一对一关联的实体的级联样式类型。 3,fetch属性是该实体的加载方式,默认为即时加载EAGER 4,optional属性表示关联的该实体是否能够存在null值,默认为ture,如果设置为false,则该实体不能为null, 5, mapperBy属性:指关系被维护端 1,@JoinColumn注释是保存表与表之间关系的字段 2,如果不设置name,默认name = 关联表的名称+”-“+关联表
VS2019是一款集成开发环境,支持多种编程语言和开发平台,其中包括.NET开发平台。近期,微软推出了.NET 5.0版本,并针对该版本提供了WebAPI接口开发的实例。 在VS2019中创建一个新的WebAPI项目,选择.NET 5.0版本。根据项目需要添加需要的NuGet包,比如Microsoft.AspNetCore.Mvc等,这些包提供了常用的WebAPI开发工具和框架,方便快捷。 接下来可以创建一个Controller类,并在其中添加一个API方法,在该方法中编写具体的业务逻辑代码。在这个例子中,我们可以编写一个获取用户信息的API。 [Route("api/[controller]")] [ApiController] public class UserController : ControllerBase { [HttpGet("{id}")] public IActionResult GetUser(int id) { //从数据库或其他数据源中获取用户信息并返回 return Ok(user); } } 用户可以通过GET请求访问该API,例如http://localhost:port/api/user/1,返回ID为1的用户信息。在这个例子中,我们使用了asp.net Core的路由功能,将API路径映射到具体的Controller和Action。 同时,我们还可以为API方法添加参数绑定功能,从URL、表单或JSON数据中提取参数。例如: [HttpPost] public IActionResult CreateUser([FromBody] User userInfo) { //将用户信息存储到数据库或其他数据源中 return CreatedAtAction(nameof(GetUser), new { id = user.Id }, user); } 上述代码演示了如何使用FromBody特性将提交的JSON数据绑定到User对象上。该API方法返回一个201 Created状态码和用户信息,同时在响应报文头中包含了该记录的URL地址。 总的来说,VS2019 + .NET 5.0提供了非常便捷和高效的WebAPI接口开发工具。开发者可以快速开发出简单而具有丰富功能的API,提供服务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值