zoukankan      html  css  js  c++  java
  • uniapp小程序--自定义分享标题

    抖音小程序需要在拍视频时标题名称改变,根据文档设置channel为video,标题为测试时的标题, 发现还是不能成功,在字节跳动开发社区找到这样的回答:检测是否引入第三方插件、代码统计(比如友盟)导致onShareAppMessage 没有执行

    我之前也在社区问过管理人员,但是回复的都没用:存在敏感词,用他们给的内容检测没有问题,后来发现是使用了友盟。

    因为我们公司项目是从微信小程序转到uniapp多端小程序,umeng配置在App.vue,友盟统计已经不能使用,就直接注释掉了。

    适用于微信、抖音小程序

    onShareAppMessage: function (options) {
      let title = "默认标题";
      if(判断是否有需要更换的标题){
        title = "需要更换的标题";
      }
      return{
        title: title
      }
    },
    

    在小程序右上角三点有分享或者拍视频。

    字节跳动内容检测方法: 官方文档

    getToken:function(){
      let that = this;
      let token={
        appid:"",//从字节跳动开发平台获取
        secret:"",//从字节跳动开发平台获取
        grant_type:"client_credential"//默认client_credential
      };
      uni.request({
        url:'https://developer.toutiao.com/api/apps/token',//官方
        data:token,
        method:"GET",
        success:(res)=> {
          let access_token=res.data.access_token;
          that.getContent(access_token);
        },
        fail: (res) => {
          console.log(res)
        }
      })
    },
    getContent:function(access_token){
      let title = "标题";
      let a ={
        channel: 'video',
        title: title,
        path: '/pages',//以/pages开头
      };
      uni.request({
        url:'https://developer.toutiao.com/api/v2/tags/text/antidirt',
        method:"POST",
        header:{
          "content-type": "application/json",//默认
          "X-Token":access_token
        },
        data:{
          "tasks":[{"content": a.toString()}]
        },
        success:(res)=>{
          console.log(res)
        },
        fail: (res) => {
        console.log(res)
        }
      })
    },
    
  • 相关阅读:
    Css进阶
    Css布局
    遇到的小问题
    MySQL 8.017连接Navicat中出现的问题
    ConcurrentHashMap图文源码解析
    HashMap图文源码解析
    接口和抽象类
    dependencies 和 devDependencies
    2020.7.7第二天
    2020.7.6第一天
  • 原文地址:https://www.cnblogs.com/cyapi/p/14759015.html
Copyright © 2011-2022 走看看