雲文檔


一 獲取訪問憑證

這里我是獲取企業自建應用,官方給的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