云文档


一 获取访问凭证

这里我是获取企业自建应用,官方给的api文档是传入app_id和app_secret,创建应用后再“凭证与基础信息中”可以找到,这里不在赘述。

官方自带postman工具的接口调试文件,咱找文档可以一一验证接口。

 

 

 作为资深程序员怎样利用java 代码实现api后端功能呢?

创建一个springboot web项目,这要不会你可以放弃了!

1.创建网络请求工具类  httpRequestFeishu

package com.ckfuture.util;


import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;

/**
 * @description: 飞书文档网络请求工具
 * @author: CKFuture
 * @since: 2021-08-31 16:23
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
public class httpRequestFeishu {


    /**
     * 请求并返回数据
     * @param url 地址
     * @param params 请求参数
     * @param headers 请求头
     * @param body 请求体
     * @param requestType 请求方式 POST、GET、PUT、DELETE
     * @return
     */
    public static String request(String url, String params, Map<String,Object> headers, JSONObject body, String requestType) {

        try {

            //判断是否携带查询参数
            if (params != "") {
                url += "?" + params;
            }

            URL realUrl = new URL(url);
            HttpURLConnection httpCon = (HttpURLConnection) realUrl.openConnection();
            httpCon.setDoOutput(true);
            httpCon.setDoInput(true);
            httpCon.setUseCaches(false);
            httpCon.setRequestMethod(requestType);

            //填充请求头
            for (Map.Entry<String, Object> entry : headers.entrySet()) {
                //System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
                httpCon.setRequestProperty(entry.getKey(), entry.getValue().toString());
            }

            // 建立实际的连接
            httpCon.connect();

            // 填充请求体  得到请求的输出流对象
            if (body !=null && body.length() > 0) {
                OutputStreamWriter writer = new OutputStreamWriter(httpCon.getOutputStream(), "UTF-8");
                writer.write(body.toString());
                writer.flush();
            }


            //获取服务器响应,通过输入流来读取url的响应
            InputStream is = httpCon.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer sbf = new StringBuffer();
            String strRead = null;
            while ((strRead = reader.readLine()) != null) {
                sbf.append(strRead);
                sbf.append("\r\n");
            }

            //关闭读取
            reader.close();
            //关闭链接
            httpCon.disconnect();
            //返回结果
            return sbf.toString();

        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            return "";
        }
    }


}

2.获取访问凭证

package com.ckfuture.util.access;

import com.alibaba.fastjson.JSON;
import com.ckfuture.pro.access.pojo.access_tokenEntity;

import com.ckfuture.util.httpRequestFeishu;
import org.json.JSONObject;


import java.util.HashMap;
import java.util.Map;

/**
 * @description: 获取企业自建应用调用凭证
 * @author: CKFuture
 * @since: 2021-09-01 08:41
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
public class access_token {
    //请求地址
    private static String url="";
    /*应用id*/
    private static String app_id = "cli_a1aee66bfdf9d013";
    /*应用密钥*/
    private static String  app_secret = "zUVkIKlNr5enEmmuWvJJccLZ7O0LGtGO";

    /**
     * 获取 app_access_token
     * @return {"code":0,"expire":4348,"msg":"ok","tenant_access_token":"t-8af0ed4da90a996518aa8acf917773876af6eabe"}
     */
    public static access_tokenEntity get_app_access_token() {
        try {
            //请求地址
            url = "https://open.feishu.cn/open-apis/auth/v3/app_access_token/internal/";
            //请求头
            Map<String, Object> headers = new HashMap<>();
            headers.put("accept", "*/*");
            headers.put("connection", "Keep-Alive");
            headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            headers.put("Content-Type", "application/json");
            //请求体
            JSONObject bodyParams = new JSONObject();
            bodyParams.put("app_id", app_id);
            bodyParams.put("app_secret", app_secret);
            //返回请求内容
            //json字符串
            String strJson = httpRequestFeishu.request(url, "", headers, bodyParams, "POST");
            //返回实体类
            access_tokenEntity entity = JSON.parseObject(JSON.parse(strJson).toString(),access_tokenEntity.class);
            return entity;
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            return null;
        }
    }

    /**
     * 获取 tenant_access_token
     * @return
     */
   public static access_tokenEntity get_tenant_access_token() {
       try {
           //请求地址
           url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal/";
           //请求头
           Map<String, Object> headers = new HashMap<>();
           headers.put("accept", "*/*");
           headers.put("connection", "Keep-Alive");
           headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
           headers.put("Content-Type", "application/json");
           //请求体
           JSONObject bodyParams = new JSONObject();
           bodyParams.put("app_id", app_id);
           bodyParams.put("app_secret", app_secret);

           //返回请求内容
           //json字符串
           String strJson = httpRequestFeishu.request(url, "", headers, bodyParams, "POST");
           //返回实体类
           access_tokenEntity entity = JSON.parseObject(JSON.parse(strJson).toString(),access_tokenEntity.class);
           //Map<String,Object> entity1 = JSON.parseObject(JSON.parse(strJson).toString(),HashMap.class);

           return entity;
       } catch (Exception ex) {
           System.out.println(ex.getMessage());
           return null;
       }
   }

}

这里访问返回的实体类代码:

package com.ckfuture.pro.access.pojo;

import lombok.Data;

/**
 * @description: 企业自建应用返回结果实体类
 * @author: CKFuture
 * @since: 2021-09-01 15:38
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
@Data
public class access_tokenEntity {
    private String code;
    private String expire;
    private String msg;
    private String tenant_access_token;
}

一 创建doc文档

根据官网文档,创建文档的前提条件是需要知道再哪个文件加下创建,所以,我们需要知道跟节点文件夹

1.对文件夹的操作,包括对根节点获取元数据、创建文件夹、获取文件夹下文档列表

package com.ckfuture.util.cloudDocument;

import com.alibaba.fastjson.JSON;
import com.ckfuture.pro.folder.pojo.children_folderEntity;
import com.ckfuture.pro.folder.pojo.create_folderEntity;
import com.ckfuture.pro.folder.pojo.meta_folderEntity;
import com.ckfuture.pro.folder.pojo.root_folderEntity;
import com.ckfuture.util.access.access_token;
import com.ckfuture.util.httpRequestFeishu;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: 文件夹
 * @author: CKFuture
 * @since: 2021-09-01 15:08
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
public class folder {

    private static String url = "";

    /**
     * 该接口用于获取 "我的空间" 的元信息
     * @return
     */
    public static root_folderEntity get_root_folder(){
       try{
           //请求地址
           url = "https://open.feishu.cn/open-apis/drive/explorer/v2/root_folder/meta";
           //请求头
           Map<String, Object> headers = new HashMap<>();
           headers.put("accept", "*/*");
           headers.put("connection", "Keep-Alive");
           headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
           headers.put("Content-Type", "application/json");
           String strAccess_token = access_token.get_tenant_access_token().getTenant_access_token();//访问凭证
           headers.put("Authorization","Bearer "+strAccess_token);

           //返回请求内容
           //json字符串
           String strJSON = httpRequestFeishu.request(url, "", headers, null, "GET");
           //返回实体类
           root_folderEntity entity = JSON.parseObject(JSON.parse(strJSON).toString(),root_folderEntity.class);

           return entity;
       }catch (Exception ex){
           return null;
       }
    }

    /**
     * 该接口用于根据 folderToken 在该 folder 下创建文件夹
     * @param folderToken 文件夹token
     * @param title 文件夹标题
     * @return
     */
    public static create_folderEntity post_create_folder(String folderToken,String title){
        try {
            //请求地址
            url = "https://open.feishu.cn/open-apis/drive/explorer/v2/folder/:folderToken";
            //请求头
            Map<String, Object> headers = new HashMap<>();
            headers.put("accept", "*/*");
            headers.put("connection", "Keep-Alive");
            headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            headers.put("Content-Type", "application/json");
            String strAccess_token = access_token.get_tenant_access_token().getTenant_access_token();//访问凭证
            headers.put("Authorization","Bearer "+strAccess_token);

            //请求体
            JSONObject bodyParams = new JSONObject();
            bodyParams.put("title", title);

            //Path Variables替换url
            url = url.replace(":folderToken", folderToken);

            //返回请求内容
            //json字符串
            String strJSON = httpRequestFeishu.request(url, "", headers, bodyParams, "POST");
            //返回实体类
            create_folderEntity entity = JSON.parseObject(JSON.parse(strJSON).toString(),create_folderEntity.class);
            return entity;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * 该接口用于根据 folderToken 获取该文件夹的元信息。
     * @param folderToken 文件夹 token
     * @return
     */
    public static meta_folderEntity get_meta_folder(String folderToken){
        try {
            //请求地址
            url="https://open.feishu.cn/open-apis/drive/explorer/v2/folder/:folderToken/meta";
            //请求头
            Map<String, Object> headers = new HashMap<>();
            headers.put("accept", "*/*");
            headers.put("connection", "Keep-Alive");
            headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            headers.put("Content-Type", "application/json");
            String strAccess_token = access_token.get_tenant_access_token().getTenant_access_token();//访问凭证
            headers.put("Authorization","Bearer "+strAccess_token);

            //Path Variables替换url
            url = url.replace(":folderToken", folderToken);

            //返回请求内容
            String strJSON = httpRequestFeishu.request(url, "", headers, null, "GET");
            //返回实体类
            meta_folderEntity entity = JSON.parseObject(JSON.parse(strJSON).toString(),meta_folderEntity.class);
            return entity;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    /**
     * 该接口用于根据 folderToken 获取该文件夹的文档清单,如 doc、sheet、folder。
     * @param folderToken 文件夹 token
     * @return
     */
    public static  children_folderEntity get_children_folder(String folderToken){
        try {
            //请求地址
            url = "https://open.feishu.cn/open-apis/drive/explorer/v2/folder/:folderToken/children";
            //请求头
            Map<String, Object> headers = new HashMap<>();
            headers.put("accept", "*/*");
            headers.put("connection", "Keep-Alive");
            headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            headers.put("Content-Type", "application/json");
            String strAccess_token = access_token.get_tenant_access_token().getTenant_access_token();//访问凭证
            headers.put("Authorization","Bearer "+strAccess_token);

            //Path Variables替换url
            url = url.replace(":folderToken", folderToken);

            //返回请求内容
            String strJSON = httpRequestFeishu.request(url, "", headers, null, "GET");
            System.out.println(strJSON);
            //返回实体类
            children_folderEntity entity = JSON.parseObject(JSON.parse(strJSON).toString(),children_folderEntity.class);
            return entity;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }


}

返回用到的实体类:

package com.ckfuture.pro.folder.pojo;

import lombok.Data;
/**
 * @description: 跟目录实体类
 * @author: CKFuture
 * @since: 2021-09-01 16:38
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
@Data
public class root_folderEntity {
    private Integer code;
    private String msg;
    private data data;
    @Data
    public class data{
        //文件夹的 token
        private String id;
        //文件夹的 token
        private String token;
        //文件夹的所有者 id
        private String user_id;
    }
}
package com.ckfuture.pro.folder.pojo;

import lombok.Data;

/**
 * @description: 文件夹元信息实体类
 * @author: CKFuture
 * @since: 2021-09-01 16:44
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
@Data
public class meta_folderEntity {
    private Integer code;
    private String msg;
    private data data;
    @Data
    public class data{
        //文件夹的 id
        private String id;
        //文件夹的标题
        private String name;
        //文件夹的 token
        private String token;
        //文件夹的创建者 id
        private String createUid;
        //文件夹的最后编辑者 id
        private String editUid;
        //文件夹的上级目录 id
        private String parentId;
        //文件夹为个人文件夹时,为文件夹的所有者 id;文件夹为共享文件夹时,为文件夹树id
        private String ownUid;
    }
}

 

package com.ckfuture.pro.folder.pojo;

import lombok.Data;

/**
 * @description: 创建文件夹实体类
 * @author: CKFuture
 * @since: 2021-09-01 16:44
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
@Data
public class create_folderEntity {
    private Integer code;
    private String msg;
    private data data;
    @Data
    public class data{
        //新创建文件夹的 url
        private String url;
        //新创建文件夹的版本号
        private Integer revision;
        //新创建文件夹的 token
        private String token;
    }
}

 

package com.ckfuture.pro.folder.pojo;

import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @description: 文件夹文档清单实体类
 * @author: CKFuture
 * @since: 2021-09-02 16:44
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
@Data
public class children_folderEntity {
    private Integer Code;
    private String msg;
    private data data;

    @Data
    public class data {
        private String parentToken;
        private List<Map<String,onechildren>> children;
        @Data
        public class onechildren {
            private String name;
            private String token;
            private String type;
        }
    }
}

2.doc文档操作

package com.ckfuture.util.cloudDocument;

import com.alibaba.fastjson.JSON;
import com.ckfuture.pro.file.pojo.create_docEntity;
import com.ckfuture.util.access.access_token;
import com.ckfuture.util.httpRequestFeishu;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: doc文档
 * @author: CKFuture
 * @since: 2021-09-02 10:48
 * @version: v1.0
 * @LastEditTime:
 * @LastEditors:
 * @copyright: hrbckfuture.com
 */
public class doc {
    private static String url="";

    /**
     * 该接口用于创建并初始化文档。
     * @param FolderToken 文件夹 token
     * @param Content 传入符合文档数据结构的字符串,若为空表示创建空文档
     * @return
     */
    public static create_docEntity post_create_doc(String FolderToken, String Content){
        try {
            //请求地址
            url = "https://open.feishu.cn/open-apis/doc/v2/create";
            //请求头
            Map<String, Object> headers = new HashMap<>();
            headers.put("accept", "*/*");
            headers.put("connection", "Keep-Alive");
            headers.put("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            headers.put("Content-Type", "application/json");
            String strAccess_token = access_token.get_tenant_access_token().getTenant_access_token();//访问凭证
            headers.put("Authorization","Bearer "+strAccess_token);

            //请求体
            JSONObject bodyParams = new JSONObject();
            bodyParams.put("FolderToken", FolderToken);
            bodyParams.put("Content", Content);

            //返回请求内容
            String strJSON = httpRequestFeishu.request(url, "", headers, bodyParams, "POST");
            //返回实体类
            create_docEntity entity = JSON.parseObject(JSON.parse(strJSON).toString(),create_docEntity.class);
            return entity;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }


}

以上测试调用:

package com.ckfuture.apiserver;

import com.ckfuture.pro.folder.pojo.children_folderEntity;
import com.ckfuture.util.cloudDocument.folder;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

public class test01 {

    @Test
    public void getUrl() {
        try {


            //1.测试获取access_token
            // access_tokenEntity s= access_token.get_tenant_access_token();
            //2.测试获取文件根节点
            //root_folderEntity s =  folder.get_root_folder();
            //3.创建文件夹
            //create_folderEntity ss = folder.post_create_folder(s.getData().getToken(),"java调用api创建文件夹");
            // 4.获取文件夹元信息 token=fldcnorfbDXGGsrAStiQ4gwC3bh
            //meta_folderEntity sss = folder.get_meta_folder(ss.getData().getToken());
            //5.创建doc文档
            //String Content="{\"title\":{\"elements\":[{\"type\":\"textRun\",\"textRun\":{\"text\":\"未名文档0826-1\",\"style\":{}}}]},\"body\":{\"blocks\":[{\"type\":\"paragraph\",\"paragraph\":{\"elements\":[{\"type\":\"textRun\",\"textRun\":{\"text\":\"恭喜你成功通过 Open API 创建了一篇在线文档。这篇文档中,描述了大部分 Open API 已经支持的文档内容,你可以对照示例代码,了解 Docs Open API 的使用方法。\",\"style\":{}}}]}},{\"type\":\"paragraph\",\"paragraph\":{\"elements\":[],\"style\":{}}},{\"type\":\"paragraph\",\"paragraph\":{\"elements\":[{\"type\":\"textRun\",\"textRun\":{\"text\":\"你可以通过文档的 URL,截取获得文档的 token,文档所有的 API 操作,都需要提供 token,例如:\",\"style\":{}}}]}},{\"type\":\"code\",\"code\":{\"language\":\"Plain Text\",\"body\":{\"blocks\":[{\"type\":\"paragraph\",\"paragraph\":{\"elements\":[{\"type\":\"textRun\",\"textRun\":{\"text\":\"https://xxx.feishu.cn/docs/\",\"style\":{}}},{\"type\":\"textRun\",\"textRun\":{\"text\":\"doccnmPiiJWfj1uk8bV7N5SzXaa\",\"style\":{\"backColor\":{\"red\":255,\"green\":246,\"blue\":122,\"alpha\":0.8}}}}],\"style\":{}}}]}}},{\"type\":\"paragraph\",\"paragraph\":{\"elements\":[],\"style\":{}}},{\"type\":\"paragraph\",\"paragraph\":{\"elements\":[{\"type\":\"textRun\",\"textRun\":{\"text\":\"从上面的例子中,可以看出:文档中的每一行都是一个 Block\",\"style\":{}}}],\"style\":{\"headingLevel\":1}}},{\"type\":\"paragraph\",\"paragraph\":{\"elements\":[{\"type\":\"textRun\",\"textRun\":{\"text\":\"文档中有多种 Block 类型,在插入内容时,你需要指定当前行是什么类型的 Block,文本类型的 Block 叫做 Paragraph。\\\",\\\"style\\\":{}}}],\\\"style\\\":{}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"一行文本可能由多个元素组成,例如这一行,就由公式 \\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"equation\\\",\\\"equation\\\":{\\\"equation\\\":\\\"E=mc^2\\\"}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\" 和 \\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"行内代码块\\\",\\\"style\\\":{\\\"codeInline\\\":true}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\" 组成。如果一些文本包含\\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"独立的样式\\\",\\\"style\\\":{\\\"backColor\\\":{\\\"red\\\":255,\\\"green\\\":246,\\\"blue\\\":122,\\\"alpha\\\":0.8}}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\",也会被视为一个独立的 element。\\\",\\\"style\\\":{}}}],\\\"style\\\":{}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[],\\\"style\\\":{}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"你可以通过 API 插入各种样式的内容\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"headingLevel\\\":1}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"支持插入有序列表\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"list\\\":{\\\"type\\\":\\\"number\\\",\\\"indentLevel\\\":1,\\\"number\\\":1}}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"你可以自己指定有序列表的编号\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"list\\\":{\\\"type\\\":\\\"number\\\",\\\"indentLevel\\\":1,\\\"number\\\":2}}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"也可以插入无序列表\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"list\\\":{\\\"type\\\":\\\"bullet\\\",\\\"indentLevel\\\":1}}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"插入更多无序列表\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"list\\\":{\\\"type\\\":\\\"bullet\\\",\\\"indentLevel\\\":1}}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"支持插入任务列表和日期提醒 \\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"reminder\\\",\\\"reminder\\\":{\\\"isWholeDay\\\":false,\\\"timestamp\\\":1609497000,\\\"shouldNotify\\\":true}}],\\\"style\\\":{\\\"list\\\":{\\\"type\\\":\\\"checkBox\\\",\\\"indentLevel\\\":1},\\\"todoUUID\\\":\\\"126f1471-f013-4ed1-9820-60f24da80677\\\"}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"或者插入引用的内容\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"quote\\\":true}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"改变文档的对齐方式,例如\\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"右对齐\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"align\\\":\\\"right\\\"}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"此外,还能灵活应用各种文字样式,增强文档的表达能力,例如:\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"align\\\":\\\"left\\\"}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"加粗 \\\",\\\"style\\\":{\\\"bold\\\":true}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"斜体 \\\",\\\"style\\\":{\\\"italic\\\":true}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"下划线 \\\",\\\"style\\\":{\\\"underLine\\\":true}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"删除线\\\",\\\"style\\\":{\\\"strikeThrough\\\":true}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\" \\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"inline code\\\",\\\"style\\\":{\\\"codeInline\\\":true}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\" \\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"高亮\\\",\\\"style\\\":{\\\"backColor\\\":{\\\"red\\\":255,\\\"green\\\":246,\\\"blue\\\":122,\\\"alpha\\\":0.8}}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"色\\\",\\\"style\\\":{\\\"backColor\\\":{\\\"red\\\":255,\\\"green\\\":246,\\\"blue\\\":122,\\\"alpha\\\":0.8}}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\" \\\",\\\"style\\\":{}}},{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"超链接\\\",\\\"style\\\":{\\\"link\\\":{\\\"url\\\":\\\"https%3A%2F%2Fopen.feishu.cn%2Fdocument%2FukTMukTMukTM%2FukjM5YjL5ITO24SOykjN\\\"}}}}]}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"或者一条删除线\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}},{\\\"type\\\":\\\"horizontalLine\\\",\\\"horizontalLine\\\":{}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[],\\\"style\\\":{}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"各种表格也支持通过 API 插入,例如\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"headingLevel\\\":1}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"普通表格\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"headingLevel\\\":2}}},{\\\"type\\\":\\\"table\\\",\\\"table\\\":{\\\"rowSize\\\":3,\\\"columnSize\\\":3,\\\"tableRows\\\":[{\\\"rowIndex\\\":0,\\\"tableCells\\\":[{\\\"columnIndex\\\":0,\\\"body\\\":{\\\"blocks\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"你可以通过表格进行排版\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"表格中的每一行也是一个 Block\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"此外,每个单元格都通过唯一的 zoneId 进行标记\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}}]}},{\\\"columnIndex\\\":1,\\\"body\\\":{\\\"blocks\\\":null}},{\\\"columnIndex\\\":2,\\\"body\\\":{\\\"blocks\\\":null}}]},{\\\"rowIndex\\\":1,\\\"tableCells\\\":[{\\\"columnIndex\\\":0,\\\"body\\\":{\\\"blocks\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"在\\\",\\\"style\\\":{\\\"codeInline\\\":true}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}}]}},{\\\"columnIndex\\\":1,\\\"body\\\":{\\\"blocks\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"飞\\\",\\\"style\\\":{\\\"codeInline\\\":true}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}}]}},{\\\"columnIndex\\\":2,\\\"body\\\":{\\\"blocks\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"书\\\",\\\"style\\\":{\\\"codeInline\\\":true}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}}]}}]},{\\\"rowIndex\\\":2,\\\"tableCells\\\":[{\\\"columnIndex\\\":0,\\\"body\\\":{\\\"blocks\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"享\\\",\\\"style\\\":{\\\"codeInline\\\":true}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}}]}},{\\\"columnIndex\\\":1,\\\"body\\\":{\\\"blocks\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"高\\\",\\\"style\\\":{\\\"codeInline\\\":true}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}}]}},{\\\"columnIndex\\\":2,\\\"body\\\":{\\\"blocks\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"效\\\",\\\"style\\\":{\\\"codeInline\\\":true}}}],\\\"style\\\":{\\\"align\\\":\\\"center\\\"}}}]}}]}],\\\"tableStyle\\\":{\\\"tableColumnProperties\\\":[{\\\"width\\\":100},{\\\"width\\\":100},{\\\"width\\\":100}]},\\\"mergedCells\\\":[{\\\"mergedCellId\\\":\\\"p47dtbcp\\\",\\\"rowStartIndex\\\":0,\\\"columnStartIndex\\\":0,\\\"rowEndIndex\\\":1,\\\"columnEndIndex\\\":3}]}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"数据表\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"headingLevel\\\":2}}},{\\\"type\\\":\\\"bitable\\\",\\\"bitable\\\":{\\\"viewType\\\":\\\"grid\\\"}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"看板\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"headingLevel\\\":2}}},{\\\"type\\\":\\\"bitable\\\",\\\"bitable\\\":{\\\"viewType\\\":\\\"kanban\\\"}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[]}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"电子表格\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"headingLevel\\\":2}}},{\\\"type\\\":\\\"sheet\\\",\\\"sheet\\\":{\\\"rowSize\\\":3,\\\"columnSize\\\":4}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[],\\\"style\\\":{}}},{\\\"type\\\":\\\"paragraph\\\",\\\"paragraph\\\":{\\\"elements\\\":[{\\\"type\\\":\\\"textRun\\\",\\\"textRun\\\":{\\\"text\\\":\\\"我是网页\\\",\\\"style\\\":{}}}],\\\"style\\\":{\\\"headingLevel\\\":2}}},{\\\"type\\\":\\\"embeddedPage\\\",\\\"embeddedPage\\\":{\\\"type\\\":\\\"xigua\\\",\\\"url\\\":\\\"https%3A%2F%2Fwww.ixigua.com%2Fiframe%2F6763174234282787341%3Fautoplay%3D0\\\",\\\"width\\\":637,\\\"height\\\":358}},{\\\"type\\\":\\\"paragraph\\\",\"paragraph\":{\"elements\":[]}}]}}";
            //create_docEntity _enttity = doc.post_create_doc("fldcnorfbDXGGsrAStiQ4gwC3bh","");
            //System.out.println(_enttity);

//6.获取文件夹下目录清单
            children_folderEntity sss = folder.get_children_folder("fldcnorfbDXGGsrAStiQ4gwC3bh");

            System.out.println("==========export=============");
            List<Map<String, children_folderEntity.data.onechildren>> list = sss.getData().getChildren();
            for (Map<String, children_folderEntity.data.onechildren> map : list) {
                for (String k : map.keySet()){
                    System.out.println(k + "\r\n \tname:" + map.get(k).getName()+" \r\n \ttoken:"+map.get(k).getToken()+" \r\n \ttype:"+map.get(k).getType());
                }
            }


        } catch (Exception ex) {

        }

    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM