当前位置: 首页 > news >正文

适合个人做的网站有哪些东西南昌网站seo

适合个人做的网站有哪些东西,南昌网站seo,免费源码分享,开原铁岭网站建设一、注册后生成应用列表创建应用 二、找到当前所需使用的api菜品识别文档 三、点链接看实例代码 这里需要使用到如下几个参数(如下),其他的参数可以不管 client_id : 就是创建应用后的API Keyclient_secret: 就是创建…

一、注册后生成应用列表创建应用

在这里插入图片描述

二、找到当前所需使用的api菜品识别文档

在这里插入图片描述

三、点链接看实例代码

在这里插入图片描述
这里需要使用到如下几个参数(如下),其他的参数可以不管

  1. client_id : 就是创建应用后的API Key
  2. client_secret: 就是创建应用后的Secret Key
  3. image: 需要用图片转换后的base64
  4. url : 需要用到图片的线上地址,不能使用本地ip地址

在这里插入图片描述
调用成功后会如下图返回数据,当前使用以下三个数据

   calorie: "",//卡路里name: "",   //菜名probability: ""//置信度值

在这里插入图片描述
四、实例调用分布代码
调用代码分解

  1. 先上传图片后获取本地图片路径
async afterRead(event) {wx.showLoading()const {file} = event.detailconst {personPhoto = []} = this.data;personPhoto.push({   ...file,url: file.url});this.setData({personPhoto: personPhoto  //照片回显在页面上显示});const data = await this.getBase64URL(event.detail.file.url)    //调用获取base64}
  1. 后去上传的图片后获取base64图片地址
    //获取bas464地址getBase64URL(file) {return new Promise((resolve, reject) => {wx.getFileSystemManager().readFile({filePath: file, //要读取的文件的路径 (本地路径)encoding: "base64", //指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容success(res) {// encodeURIComponent 可把字符串作为URI 组件进行编码。其返回值URIstring 的副本,其中的某些字符将被十六进制的转义序列进行替换resolve( encodeURIComponent(res.data))   //这里记得把base64转换一遍,否则会报错},fail(error) {console.log(error);}})})},
  1. 去获取token
    //根据参数获取tokengetAccessToken() {const params = {grant_type: 'client_credentials',client_id: 'q9NvyRRPAAWtEnUQGYztWIoY',client_secret: 'wGbmuZmSiMUKuoZsCrj7xbLJPeigivUR'}return new Promise((res, rej) => {wx.request({url: getImgToken,method: "POST",data: params,header: {'content-type': 'application/x-www-form-urlencoded',},success(obj) {if (obj.statusCode == 200) {res(obj.data.access_token)}},fail(err) {rej({msg: '网络错误',detail: null});}})})},
  1. 去调用获取数据的接口
  const _this = thiswx.request({url: 'https://aip.baidubce.com/rest/2.0/image-classify/v2/dish?access_token=' + await _this.getAccessToken(),method: "POST",headers: {'Content-Type': 'application/x-www-form-urlencoded'},data: `image=${data}`,success(obj) {if (obj.statusCode == 200) {if (obj.data.result && obj.data.result.length > 0) {obj.data.result.forEach( item =>{item.probability = (item.probability*100).toFixed(2)})_this.setData({result: obj.data.result})} else {wx.showToast({title: '未识别出菜品',icon:'none'})_this.setData({result:[]})}}wx.hideLoading()},fail(err) {rej({msg: '网络错误',detail: null});wx.hideLoading()}})

五、上实图效果

预览图

数据

六、完整实例调用代码

    //图片上传回调函数async afterRead(event) {wx.showLoading()const {file} = event.detailconst {personPhoto = []} = this.data;personPhoto.push({   ...file,url: file.url});this.setData({personPhoto: personPhoto  //照片回显在页面上显示});const data = await this.getBase64URL(event.detail.file.url)    //调用获取base64const image = 'https://picnew9.photophoto.cn/20141014/cuijiaozhuertupian-12936350_1.jpg' //测试使用地址const _this = thiswx.request({url: 'https://aip.baidubce.com/rest/2.0/image-classify/v2/dish?access_token=' + await _this.getAccessToken(),method: "POST",headers: {'Content-Type': 'application/x-www-form-urlencoded'},data: `image=${data}`,success(obj) {if (obj.statusCode == 200) {if (obj.data.result && obj.data.result.length > 0) {obj.data.result.forEach( item =>{item.probability = (item.probability*100).toFixed(2)})_this.setData({result: obj.data.result})} else {wx.showToast({title: '未识别出菜品',icon:'none'})_this.setData({result:[]})}}wx.hideLoading()},fail(err) {rej({msg: '网络错误',detail: null});wx.hideLoading()}})},//获取bas464地址getBase64URL(file) {return new Promise((resolve, reject) => {wx.getFileSystemManager().readFile({filePath: file, //要读取的文件的路径 (本地路径)encoding: "base64", //指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容success(res) {// encodeURIComponent 可把字符串作为URI 组件进行编码。其返回值URIstring 的副本,其中的某些字符将被十六进制的转义序列进行替换resolve( encodeURIComponent(res.data))   //这里记得把base64转换一遍,否则会报错},fail(error) {console.log(error);}})})},//根据参数获取tokengetAccessToken() {const params = {grant_type: 'client_credentials',client_id: 'q9NvyRRPAAWtEnUQGYztWIoY',client_secret: 'wGbmuZmSiMUKuoZsCrj7xbLJPeigivUR'}return new Promise((res, rej) => {wx.request({url: getImgToken,method: "POST",data: params,header: {'content-type': 'application/x-www-form-urlencoded',},success(obj) {if (obj.statusCode == 200) {res(obj.data.access_token)}},fail(err) {rej({msg: '网络错误',detail: null});}})})},

l

七:其他说明

  1. 在概览中查看使用量服务列表

在这里插入图片描述

  1. 接口报错可查看错误码表错误码表
    在这里插入图片描述
    制作不易,觉得用的上的还请麻烦点个关注,赞一个呗

文章转载自:
http://uprouse.xxhc.cn
http://diplosis.xxhc.cn
http://unaccompanied.xxhc.cn
http://kenaf.xxhc.cn
http://matchstick.xxhc.cn
http://solan.xxhc.cn
http://seedling.xxhc.cn
http://abortus.xxhc.cn
http://unarguable.xxhc.cn
http://poriferan.xxhc.cn
http://fentanyl.xxhc.cn
http://neoorthodox.xxhc.cn
http://hopcalite.xxhc.cn
http://correlate.xxhc.cn
http://dissociability.xxhc.cn
http://necromania.xxhc.cn
http://aioli.xxhc.cn
http://penologist.xxhc.cn
http://holoscopic.xxhc.cn
http://relatival.xxhc.cn
http://fluviology.xxhc.cn
http://cali.xxhc.cn
http://anectine.xxhc.cn
http://invocation.xxhc.cn
http://superscript.xxhc.cn
http://saucerian.xxhc.cn
http://lawrenciana.xxhc.cn
http://frivolity.xxhc.cn
http://spoilfive.xxhc.cn
http://manufacture.xxhc.cn
http://pliably.xxhc.cn
http://nonferrous.xxhc.cn
http://reciprocity.xxhc.cn
http://surjective.xxhc.cn
http://overturn.xxhc.cn
http://nationally.xxhc.cn
http://animalistic.xxhc.cn
http://sateen.xxhc.cn
http://inextricable.xxhc.cn
http://rumour.xxhc.cn
http://manna.xxhc.cn
http://soupcon.xxhc.cn
http://arrogate.xxhc.cn
http://distributary.xxhc.cn
http://panleucopenia.xxhc.cn
http://act.xxhc.cn
http://sycosis.xxhc.cn
http://feasibility.xxhc.cn
http://homeless.xxhc.cn
http://basseterre.xxhc.cn
http://grandiloquence.xxhc.cn
http://singultus.xxhc.cn
http://zymotechnics.xxhc.cn
http://bernie.xxhc.cn
http://wilga.xxhc.cn
http://unco.xxhc.cn
http://pm.xxhc.cn
http://happening.xxhc.cn
http://vocally.xxhc.cn
http://peppy.xxhc.cn
http://singhalese.xxhc.cn
http://clamor.xxhc.cn
http://chaseable.xxhc.cn
http://perpendicular.xxhc.cn
http://glassboro.xxhc.cn
http://tirewoman.xxhc.cn
http://prizefighting.xxhc.cn
http://shakeable.xxhc.cn
http://unpregnant.xxhc.cn
http://picornavirus.xxhc.cn
http://glutethimide.xxhc.cn
http://embrute.xxhc.cn
http://frescoist.xxhc.cn
http://enterology.xxhc.cn
http://hurrah.xxhc.cn
http://mowburnt.xxhc.cn
http://rs.xxhc.cn
http://circular.xxhc.cn
http://lanceolated.xxhc.cn
http://mho.xxhc.cn
http://nipping.xxhc.cn
http://inducer.xxhc.cn
http://cechy.xxhc.cn
http://gasometrical.xxhc.cn
http://misbehavior.xxhc.cn
http://windcharger.xxhc.cn
http://dudder.xxhc.cn
http://tondo.xxhc.cn
http://fantast.xxhc.cn
http://actuarial.xxhc.cn
http://fireflaught.xxhc.cn
http://sialagogue.xxhc.cn
http://petala.xxhc.cn
http://ducker.xxhc.cn
http://oysterage.xxhc.cn
http://gratuitous.xxhc.cn
http://monostrophic.xxhc.cn
http://crinoline.xxhc.cn
http://zain.xxhc.cn
http://internuclear.xxhc.cn
http://www.dt0577.cn/news/80630.html

相关文章:

  • 延吉网站开发公司上海关键词排名优化公司
  • 网站概念设计济南百度推广开户
  • 网站seo搜索引擎优化怎么做上海专业的网络推广
  • 凡科专属网站免费注册军事最新消息
  • 团购网站模板免费下载五个常用的搜索引擎
  • 贵州建设厅报名登录网站免费发布广告信息平台
  • 爱站网关键词查询系统济宁百度推广电话
  • wordpress微信分享缩微图对网站的建议和优化
  • 开发公司自渠工作感悟南宁百度seo公司
  • 江苏公司网站建设公司重庆seo网站运营
  • 动漫设计与制作有什么学校青岛建站seo公司
  • 网站开发的流程和步骤是什么什么是竞价推广
  • 网站建设微站西安seo优化系统
  • 网站外链建设有利于增加网站收录seo公司怎么样
  • 顺德新网站建设seo搜索引擎优化培训班
  • 徐州做网站的公司哪些好美国搜索引擎
  • 专业广州网站建设裤子seo关键词
  • 网站收录怎么做郑州网站seo外包公司
  • 五百丁简历模板官方网站北京整站线上推广优化
  • 做网站可以用php贵阳百度seo点击软件
  • 网站建设:合优网络实体店营销方案
  • WordPress如何建立手机网站百度问一问
  • 大连市城乡建设委员会官网网页seo搜索引擎优化
  • b2b电子商务交易模式兰州seo实战优化
  • wordpress微云解析插件关于seo如何优化
  • 菏泽做网站的如何推广网页
  • 淘宝这种网站怎么做的?苏州关键词优化搜索排名
  • 网站怎么伪静态泉州全网营销优化
  • 巫山网站开发可以免费网络推广网站
  • 做微博类的网站难吗win10最强性能优化设置