调用图像识别里数据问题
秋天的收获588 发布于2018-03 浏览:2231 回复:12
0
收藏
调用接口后,显示如下信息,如何解决?
log_id": 1548050132715252919, "error_code": 216101, "error_msg": "param image not exist"
收藏
点赞
0
个赞
共12条回复 最后由秋天的收获588回复于2018-03
#13秋天的收获588回复于2018-03

好的,谢谢你

0
#12用户已被禁言回复于2018-03
#11 秋天的收获588回复
data: { image: '图片的base64不需要urlencode' },   就是这段代码,有没有示例,我看看
展开

我不是前端人员。前端的图片转base64没搞过。我只是反馈出你的问题所在。具体图片的base64数据如何获取你可以百度一下。我测试过JS的一些方法,很慢。

我自己的微信小程序是通过请求后台进行请求接口的。

1
#11秋天的收获588回复于2018-03
#9 用户已被禁言回复
仔细看帖子的评论吧亲。我把index.js index.wxml都贴出来了
展开

data: {
image: '图片的base64不需要urlencode'
},

 

就是这段代码,有没有示例,我看看

0
#10秋天的收获588回复于2018-03
#9 用户已被禁言回复
仔细看帖子的评论吧亲。我把index.js index.wxml都贴出来了
展开

我的QQ是 2379435910  你能远程帮我搞一下嘛?真的不会,我是个人业余爱好

0
#9用户已被禁言回复于2018-03
#8 秋天的收获588回复
能不能贴个该部分的示例给我看看

仔细看帖子的评论吧亲。我把index.js index.wxml都贴出来了

1
#8秋天的收获588回复于2018-03
#7 用户已被禁言回复
你的代码也是比较明显的显示你没有写data和image参数哦

能不能贴个该部分的示例给我看看

0
#7用户已被禁言回复于2018-03
#3 秋天的收获588回复
是植物识别调用接口 代码如下: url: 'https://aip.baidubce.com/rest/2.0/image-classify/v1/plant?access_token=24.e3983eca48beba5fea44bcd444853c8f.2592000.1524042089.282335-10953112', //仅为示例,非真实的接口地址 header: { 'content-type': 'application/x-www-form-urlencoded' }, filePath: tempFilePaths[0], name:'file', success: function(res){ //恩 console.log(res.data+"花1")
展开

你的代码也是比较明显的显示你没有写data和image参数哦

1
#6用户已被禁言回复于2018-03
#5 用户已被禁言回复
微信小程序直接发送wx.request请求是吗?
  • index.js代码
//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  xaiDemo:function(){
    wx.request({
      url: 'https://aip.baidubce.com/rest/2.0/image-classify/v1/plant?access_token=自己的token',
      method:'POST',
      data: {
        image: '图片的base64不需要urlencode'
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res.data)
      },
      fail:function(res){
        console.log(res);
      }
    })
  },
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})

 

  • index.wxml代码


  
     获取头像昵称 
    
      
      {{userInfo.nickName}}
    
  
  
    {{motto}}
  
  测试

1
#5用户已被禁言回复于2018-03
#4 秋天的收获588回复
微信小程序调用的,前面有段语言 uploadImage: function() { var that = this wx.chooseImage({ success: function(res) { that.setData({ source: res.tempFilePaths }) var tempFilePaths = res.tempFilePaths
展开

微信小程序直接发送wx.request请求是吗?

0
#4秋天的收获588回复于2018-03

微信小程序调用的,前面有段语言

uploadImage: function() {
var that = this
wx.chooseImage({
success: function(res) {
that.setData({ source: res.tempFilePaths })
var tempFilePaths = res.tempFilePaths

0
#3秋天的收获588回复于2018-03
#2 用户已被禁言回复
具体哪个接口。什么语言调用?是API还是SDK调用呢?这些描述清楚才方便大家帮你解决 你的错误很明显。image参数不存在。  
展开

是植物识别调用接口

代码如下:
url: 'https://aip.baidubce.com/rest/2.0/image-classify/v1/plant?access_token=24.e3983eca48beba5fea44bcd444853c8f.2592000.1524042089.282335-10953112', //仅为示例,非真实的接口地址
header: {
'content-type': 'application/x-www-form-urlencoded'
},
filePath: tempFilePaths[0],
name:'file',
success: function(res){
//恩
console.log(res.data+"花1")

0
#2用户已被禁言回复于2018-03

具体哪个接口。什么语言调用?是API还是SDK调用呢?这些描述清楚才方便大家帮你解决

你的错误很明显。image参数不存在。

 

1
TOP
切换版块