Feishu Development Study Notes (1) - Application Creation and Testing

Feishu Development Study Notes (1) - Application Creation and Testing

I. Introduction

Among the office IM software currently used by large enterprises, Feishu has the best reputation. It must be said that Byte has its own unique competitiveness in product development, such as Douyin, Toutiao, and Feishu. In terms of the experience of office meetings and cloud documents, other office IM software can be said to be completely unmatched. In order to collect some data and create documents efficiently in the office, it is very meaningful to learn the development of Feishu. Based on this, I want to start with Feishu's development documents, learn some of Feishu's secondary development solutions, and record them as study notes.

2. Development documents

Feishu’s development document address is: https://open.feishu.cn/document/home/index
According to the capabilities of the application In terms of form, Feishu applications can be mainly divided into four categories: robots, web pages, applets, and widgets.
However, for simple secondary development, Feishu provides powerful API documentation and toolbench. In other words, using python or C#, you can complete the development of Feishu and the operation of cloud documents by making simple API calls.
Then, first use the Feishu API toolbench and API functions to conduct simple development, which is a more suitable introductory learning.

2.1 Feishu Open Platform

Feishu Open Platform:https://open.feishu.cn/app?lang=zh-CN
After opening, enter Open Platform page.
Before developing tools, you need to build an application yourself. The purpose of this is just to create an application entrance as the application entrance and credentials.
After creation, the development toolbench and tutorials will appear.
Insert image description here
In designing an application, the first step is to introduce the document.
Introduction to open capabilities: https://open.feishu.cn/document/client-docs/intro
Feishu In the framework of the open platform, all capabilities of the open platform, whether it is small programs/H5/robots or development API interfaces, can be developed through the API provided by Feishu.
Insert image description here
Excellent development cases: Address
Here are some good development cases, one of which is:< a i=12>Using server-side OpenAPI to automatically export documents is very good. If you browse around more, you can learn a lot of development ideas and ideas.

2.2 Build the application

Click to create a self-built enterprise application
Insert image description here

After the creation is completed, you can not add application capabilities, such as "small programs/components/robots".

Insert image description here

Since the official application needs to apply for permission from the enterprise after it is released, debugging is troublesome, so a test version is created here first.
It is more convenient to use testing companies and personnel to test APIs.

Insert image description here
After switching to the test application, you can apply for application permissions related to API operations.
Insert image description here

In the test application, you are the administrator by default, so when you apply for permission, you apply and activate it.
Insert image description here

2.3 Feishu API

Insert image description here

After the test application and permissions are enabled, you can see an API debugging platform like this, with the application's authentication credentials on the left.
There is a list of all APIs on the lower left, and on the right It is the request header and request body for API debugging. After filling in the request parameters as required, you can click
to start debugging for API debugging.
Insert image description here
The API provided by Feishu Open Platform follows the RESTful style, and the format of the request URL is:
Insert image description here
The process of calling the server API is shown in the figure below.

Insert image description here

Create application. In the developer backend, create self-built applications or store applications based on actual needs.
Only users with ISV qualifications can create store apps. For a detailed introduction to ISVs, please refer to How to Join the Feishu Open Platform.
Obtain access credentials. Feishu Open Platform has set up multiple access credentials (also called access_token). Different access credentials represent different resource access rights. When calling the API, you need to carry access credentials in the HTTP Header in order to obtain resource information within the permission scope.

Apply for API permissions. If you want to call the API, you need to obtain the interface calling permission first; if it involves accessing sensitive fields, you also need to obtain the permission to access the sensitive fields.

(Optional) Configure app data permissions. After an application applies for permissions on some APIs (for example, address book, Feishu HR Enterprise Edition), it also needs to configure the corresponding data permissions and submit them for review. Only after the approval is passed and the permission takes effect can the API be successfully called to obtain data. Otherwise, a permission error will be returned when calling the API.

(Optional) Set up an IP whitelist. To improve application security, you can set an IP whitelist for the application. Feishu Open Platform will respond only if the source IP is in the whitelist, otherwise the request will be rejected.

Call API. After completing the above steps, you are ready to call the API. You can refer to the API documentation to learn about the specific functions of the API.

3. Test application

3.1 Authentication

After refreshing the password token, in the self-built application acquisition of the API, copy the app_id and app_secret in the API request body, which are needed for development.
Insert image description here

3.2 Test API

Take the self-built application to obtain the tenant_access_token API as an example. The parameters that need to be filled in in the test workbench are the request header and the request body.
Insert image description here
In the test workbench, the request header and request body have been automatically filled in. Click Start debugging to see the response results.
Insert image description here
The returned status code is 200, indicating that the test API is successful.
The returned data is a json string, which returns four results: code, expire, msg and tenant_access_token, and the fourth one is the password.
At this point, the initial application creation and testing has been successful, and the result of tenant_access_token has been queried using the API.

Guess you like

Origin blog.csdn.net/qq_43662503/article/details/129572205