Interface calling method and device, equipment and storage medium
By verifying the API call request of a third party on the server and providing only the API configuration information allowed to be called, the problem of difficult data security during the development of Android applications is solved, and the effect of improving data security is achieved.
Patent Information
- Application Number
- CN202510094707.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-05-16
AI Technical Summary
During the development of Android applications, third parties obtain the source code and call configuration information of the full API, making it difficult to ensure data security and reduce data security.
After receiving the API call request from a third party on the server, verify whether the third party calls the API legally, and only provide the third party with the configuration information of the API allowed to be called, rather than the configuration information of the full API.
It effectively guarantees the security of data during the development of Android applications, prevents data leakage, and improves data security.
Smart Images

Figure CN120010961A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, in particular to the field of computer technology, and specifically to an interface calling method, device, equipment and storage medium. Background Art
[0002] In the process of developing Android applications, the development device can package different software development kit (SDK) channel packages for different third parties, and send the corresponding SDK channel packages to the third parties through the server. The third party can obtain the corresponding SDK channel package and call the application programming interface (API) of the Android application through the corresponding SDK channel package to configure the functions of the Android application through the API, thereby realizing the development of the Android application.
[0003] Specifically, the implementation process of a third party obtaining the corresponding SDK channel package can be: the third party sends a request to call the API to the server. Correspondingly, the server receives the request to call the API from the third party and sends the corresponding SDK channel package to the third party. Among them, the corresponding SDK channel package includes the source code of the full API involved in the development of Android applications and the calling configuration information of the full API.
[0004] In other words, a third party can obtain the source code of all APIs involved in the process of developing Android applications and the calling configuration information of all APIs. This cannot well protect the security of the data involved in the process of developing Android applications, thereby reducing the security of the data involved in the process of developing Android applications. Summary of the invention
[0005] The present application provides an interface calling method, apparatus, device and storage medium, which can ensure the security of data involved in the process of developing Android applications as much as possible, and thus improve the security of data involved in the process of developing Android applications as much as possible.
[0006] To achieve the above purpose, the technical solution of this application is as follows:
[0007] According to the first aspect of the present application, there is provided an interface calling method, which is applied to a server, and the method comprises: receiving an application programming interface API call request from a third party, the API call request being used to request calling a first API; in a case where the API set corresponding to the third party includes the first API, sending API configuration information to the third party, wherein the API set corresponding to the third party includes an API that the third party is allowed to call, and the API configuration information includes configuration information of the API that the third party is allowed to call.
[0008] In a possible implementation, the API configuration information includes API source code and API call configuration information.
[0009] In a possible implementation, before receiving an API call request from a third party, the method further includes: receiving an Android library project archive file AAR from a development device, the AAR including an API set corresponding to the third party, or the AAR including an API set corresponding to the third party and the source code of each API in the API set corresponding to the third party.
[0010] In a possible implementation, the source code of each API in the API set corresponding to the third party includes the common code and the dedicated code of the API, and the common code of the API is the code shared by the API and other APIs in the API set.
[0011] According to the second aspect provided by the present application, an interface calling method is provided, which is applied to a third party, and the method includes: sending an API calling request to a server, the API calling request is used to request to call a first API; receiving API configuration information from the server, the API configuration information is triggered to be sent when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes an API allowed to be called by the third party, and the API configuration information includes configuration information of the API allowed to be called by the third party.
[0012] In a possible implementation, the API configuration information includes API source code and API call configuration information.
[0013] According to the third aspect provided by the present application, an interface calling device is provided, which is applied to a server side, and the interface calling device includes: a processing unit and a communication unit; the processing unit is used to instruct the communication unit to receive an application programming interface API call request from a third party, and the API call request is used to request to call a first API; the processing unit is also used to instruct the communication unit to send API configuration information to the third party when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes an API allowed to be called by the third party, and the API configuration information includes configuration information of the API allowed to be called by the third party.
[0014] In a possible implementation, the API configuration information includes source code of the first API and call configuration information of the first API.
[0015] In a possible implementation, the processing unit is further used to instruct the communication unit to receive an Android library project archive file AAR from a development device, where the AAR includes an API set corresponding to a third party, or the AAR includes an API set corresponding to a third party and source code for each API in the API set corresponding to the third party.
[0016] In a possible implementation, the source code of each API in the API set corresponding to the third party includes the common code and the dedicated code of the API, and the common code of the API is the code shared by the API and other APIs in the API set.
[0017] According to the fourth aspect provided by the present application, an interface calling device is provided, which is applied to a third party, and the interface calling device includes: a processing unit and a communication unit; the processing unit is used to instruct the communication unit to send an API call request to the server, and the API call request is used to request to call a first API; the processing unit is also used to instruct the communication unit to receive API configuration information from the server, and the API configuration information is triggered to be sent when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes an API allowed to be called by the third party, and the API configuration information includes configuration information of the API allowed to be called by the third party.
[0018] According to the fifth aspect provided by the present application, an electronic device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to execute instructions to implement the method of the above-mentioned first aspect, second aspect and any possible implementation manner thereof.
[0019] According to the sixth aspect provided by the present application, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method of the above-mentioned first aspect, second aspect and any possible implementation manner thereof.
[0020] According to the seventh aspect provided by the present application, a computer program product is provided, the computer program product comprising computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method of the above-mentioned first aspect, second aspect and any possible implementation manner thereof.
[0021] Therefore, the above technical features of the present application have the following beneficial effects:
[0022] (1) The server receives an API call request from a third party, and when the server verifies that the third party can call the first API, that is, the API set corresponding to the third party includes the first API indicated by the API call request, the server provides the third party with configuration information of the API that the third party is allowed to call, rather than sending the configuration information of the full API to the third party. In this way, even if data is leaked, the configuration information of the full API will not be leaked, thereby ensuring the security of data involved in the process of developing Android applications as much as possible, and thus improving the security of data involved in the process of developing Android applications as much as possible.
[0023] (2) The API configuration information includes the source code of the API that is allowed to be called by a third party and the calling configuration information of the API that is allowed to be called by a third party. The source code of the API that is allowed to be called by a third party provides the original data for the third party to configure the API, while the calling configuration information of the API that is allowed to be called by a third party provides the third party with instructions for configuring the API. This can provide more comprehensive information for the third party to call the API, so as to ensure that the third party can call the API normally as much as possible.
[0024] (3) The server receives an AAR from the development device, where the AAR includes the API set corresponding to the third party, or the AAR includes the API set corresponding to the third party and the source code of each API in the API set corresponding to the third party. Since in the interface call process, the API set corresponding to the third party can be used to subsequently verify whether the first API requested by the third party is legal, and the source code of each API in the API set corresponding to the third party can be used to configure the third party API, the development device provides the AAR to the server, which can provide data preparation for the subsequent interface call process.
[0025] (4) The source code of each API in the API set corresponding to the third party includes the common code and the dedicated code of the API, wherein the common code of the API is the code shared by the API and other APIs in the API set. That is to say, the interface calling method recorded in this application not only transmits the common code for configuring the API, but also adds the dedicated code, so that the differences between different APIs can be displayed on the basis of ensuring the normal configuration of the API by the third party, so that the third party can distinguish different APIs more clearly.
[0026] It should be noted that the technical effects brought about by any implementation method in the second to seventh aspects can refer to the technical effects brought about by the corresponding implementation method in the first aspect, and will not be repeated here.
[0027] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.
[0029] Figure 1 is a structural diagram of an interface calling system according to an exemplary embodiment;
[0030] Figure 2 is a schematic diagram showing the composition of an interface calling device according to an exemplary embodiment;
[0031] Figure 3 is a flow chart of an interface calling method according to an exemplary embodiment;
[0032] Figure 4 is a flowchart of another interface calling method according to an exemplary embodiment;
[0033] Figure 5 is a flowchart of another interface calling method according to an exemplary embodiment;
[0034] Figure 6 The figure is a block diagram of an interface calling device according to an exemplary embodiment. DETAILED DESCRIPTION
[0035] In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0036] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0037] In the process of developing Android applications, developers will generate an Android application package (APK) file. Users can install and use Android applications on their devices by downloading the APK file. Developers can package different SDK channel packages for Android applications for different third parties. Third parties can call the API of the Android application through the corresponding SDK channel package. Different third parties correspond to different SDK channel packages. For example, when an Android application needs to call the API of another Android application, the Android application communicates with the other Android application through the Android interface definition language (AIDL). The other Android application encapsulates the AIDL into the corresponding SDK channel package for the Android application to use.
[0038] When a third party needs to call the API of an Android application, it can send an API call request to the server, and the server will send the SDK channel package corresponding to the third party to the third party. The SDK channel package corresponding to the third party includes the source code and full API documentation of the full API involved in the process of developing Android applications, where the full API documentation includes the calling configuration information of the full API. In other words, the third party can obtain the source code and calling configuration information of the full API involved in the process of developing Android applications, which cannot well protect the security of the data involved in the process of developing Android applications, thereby reducing the security of the data involved in the process of developing Android applications.
[0039] In view of this, an embodiment of the present application provides an interface calling method, in which a server receives an API calling request from a third party, and when the server verifies that the third party is able to call the first API, that is, when the API set corresponding to the third party includes the first API indicated by the API calling request, the server provides the third party with configuration information of the API allowed to be called by the third party, rather than sending the configuration information of the full API to the third party. In this way, even if data is leaked, the configuration information of the full API will not be leaked, thereby ensuring the security of data involved in the process of developing Android applications as much as possible, and thereby improving the security of data involved in the process of developing Android applications as much as possible.
[0040] For ease of understanding, the interface calling method provided by the present application is specifically introduced below with reference to the accompanying drawings.
[0041] Figure 1 The structure diagram of an interface calling system 10 provided in an embodiment of the present application is shown. The interface calling system 10 may include at least one server 101 and at least one third party 102, and the server 101 may be connected to the third party 102 for communication. Figure 1 Only one server 101 and one third party 102 are shown. The embodiment of the present application does not impose any restriction on the number of the server 101 and the third party 102.
[0042] The server 101 is used to receive an API call request from a third party, where the API call request is used to request to call a first API; when the API set corresponding to the third party includes the first API, API configuration information is sent to the third party, wherein the API set corresponding to the third party includes an API allowed to be called by the third party, and the API configuration information includes configuration information of the API allowed to be called by the third party.
[0043] Optionally, the server 101 can be a large-capacity device with wireless communication capabilities (for example, a server integrating a large number of boards), which can be deployed on land, including indoors or outdoors, handheld or vehicle-mounted, on the water (such as ships, etc.), or in the air (such as airplanes, balloons, and satellites, etc.).
[0044] The third party 102 is used to send an API call request to the server, where the API call request is used to request to call the first API; and receive API configuration information from the server, where the API configuration information is triggered to be sent when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes an API that the third party is allowed to call, and the API configuration information includes configuration information of the API that the third party is allowed to call.
[0045] Optionally, the third party 102 includes, but is not limited to: electronic device manufacturing equipment, Internet service providing equipment, software development equipment and application providing equipment, content providing equipment, accessory supply equipment, and cloud service providing equipment.
[0046] It should be noted that Figure 1 This is just an exemplary framework diagram. Figure 1 The number of nodes included in the Figure 1 In addition to the functional nodes shown, the interface calling system 10 may also include other nodes, and this application does not impose any limitation on this.
[0047] The application scenarios of the embodiments of the present application are not limited. The system architecture and business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. It is known to those skilled in the art that with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0048] When implementing it specifically, Figure 1 The equipment in Figure 2 The structure shown, or including Figure 2 Parts shown. Figure 2 The present invention provides a schematic diagram of the composition of an interface calling device 20 provided in an embodiment of the present invention. The interface calling device 20 may be a server 101 or a chip or a system on chip in the server 101. Alternatively, the communication device 20 may be a third party 102 or a chip or a system on chip in the third party 102. Figure 2 As shown, the interface calling device 20 may include a processor 201 , a communication line 202 , a communication interface 203 , and a memory 204 .
[0049] Furthermore, the interface calling device 20 may also include a communication interface 203 and a memory 204. The processor 201, the memory 204 and the communication interface 203 may be connected via a communication line 202.
[0050] The processor 201 is a CPU, a general processor, a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof. The processor 201 may also be other devices with processing functions, such as circuits, devices, or software modules, without limitation.
[0051] The communication line 202 is used to transmit information between the components included in the interface calling device 20.
[0052] The communication interface 203 is used to communicate with other devices or other communication networks. The other communication networks may be Ethernet, radio access network (RAN), wireless local area network (WLAN), etc. The communication interface 203 may be a module, a circuit, a communication interface or any device capable of implementing an interface call.
[0053] The memory 204 is used to store instructions, where the instructions may be computer programs.
[0054] The memory 204 may be a read-only memory (ROM) or other types of static storage devices that can store static information and / or instructions, or a random access memory (RAM) or other types of dynamic storage devices that can store information and / or instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, etc., without limitation.
[0055] It should be noted that the memory 204 can exist independently of the processor 201, or can be integrated with the processor 201. The memory 204 can be used to store instructions or program codes or some data, etc. The memory 204 can be located in the interface calling device 20, or can be located outside the interface calling device 20, without limitation. The processor 201 is used to execute the instructions stored in the memory 204 to implement the network switching method provided in the following embodiments of the present application.
[0056] In an example, the processor 201 may include one or more CPUs, for example, CPU0 and CPU1 (not shown in the figure).
[0057] As an optional implementation, the interface calling device 20 includes multiple processors.
[0058] As an optional implementation, the interface calling device 20 further includes an output device and an input device. For example, the input device is a keyboard, a mouse, a microphone or a joystick, and the output device is a display screen, a speaker, and the like.
[0059] It should be noted that the interface calling device 20 can be a desktop computer, a portable computer, a network server, a mobile phone, a tablet computer, a wireless terminal, an embedded device, a chip system or a Figure 2 In addition, Figure 2 The composition shown in the Figure 1 as well as Figure 2 The limitations of each device in Figure 2 In addition to the parts shown, Figure 1 as well as Figure 2 The various devices shown may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0060] In the embodiment of the present application, the chip system may be composed of a chip, or may include a chip and other discrete devices.
[0061] In addition, the actions, terms, etc. involved in the various embodiments of the present application can refer to each other without limitation. The message name or parameter name in the message exchanged between the various devices in the embodiments of the present application is only an example, and other names can also be used in the specific implementation without limitation.
[0062] Combine the following Figure 1 The interface calling system shown describes the interface calling method of the embodiment of the present application. Among them, the actions, terms, etc. involved in the various embodiments of the present application can refer to each other without limitation. The message name or parameter name in the message exchanged between the various devices in the embodiment of the present application is only an example, and other names can also be used in the specific implementation without limitation. The actions involved in the various embodiments of the present application are only an example, and other names can also be used in the specific implementation, such as: "included in" in the embodiment of the present application can also be replaced by "carried on" or "carried in", etc.
[0063] In order to solve the problems existing in the above-mentioned prior art, the embodiment of the present application proposes an interface calling method, which can ensure the security of data involved in the process of developing Android as much as possible, and thus improve the security of data involved in the process of developing Android applications as much as possible. The interface calling method provided by the embodiment of the present application includes an interface calling process and an interface configuration process.
[0064] The "interface calling process" is described below.
[0065] like Figure 3As shown, the "interface calling process" includes S301-S302.
[0066] S301: A third party sends an API call request to a server, and correspondingly, the server receives the API call request from the third party.
[0067] The API call request is used to request to call the first API.
[0068] Optionally, the API call request may include the identifier of the third party, the identifier of the first API, and call indication information, where the call indication information is used to indicate the request to call the interface. Of course, the above is an exemplary description of the API call request, and the API call request may also include other information, such as the identifier of the server, and the embodiments of the present application do not impose any restrictions on this.
[0069] S302: When the API set corresponding to the third party includes the first API, the server sends API configuration information to the third party. Correspondingly, the third party receives the API configuration information from the server.
[0070] The API set corresponding to the third party includes APIs that are allowed to be called by the third party, and the API configuration information includes configuration information of the APIs that are allowed to be called by the third party.
[0071] That is to say, after receiving an API call request from a third party, the server can verify the API requested by the third party, that is, determine whether the first API is included in the API set corresponding to the third party. If the API set corresponding to the third party includes the first API, it can be determined that the server has configured the first API for the third party, that is, the third party is making a legitimate call, so that the server can subsequently send API configuration information to the third party so that the third party can call the API based on the API configuration information.
[0072] In addition, optionally, when the API set corresponding to the third party does not include the first API, the server does not send API configuration information to the third party, thereby avoiding illegal calls to the third party to obtain API configuration information, thereby improving the security of information transmission.
[0073] In an optional implementation, the API configuration information includes the source code of the API and the calling configuration information of the API.
[0074] It is understandable that the source code of the API allowed to be called by third parties provides the original data for the third-party to configure the API, and the calling configuration information of the API allowed to be called by third parties provides the third party with instructions for configuring the API. This can provide more comprehensive information for third parties to call the API, so as to ensure that the third party can call the API normally as much as possible.
[0075] In the interface calling method provided in the embodiment of the present application, the server receives an API calling request from a third party, and when the server verifies that the third party can call the first API, that is, the API set corresponding to the third party includes the first API indicated by the API calling request, the server provides the third party with configuration information of the API allowed to be called by the third party, rather than sending the configuration information of the full API to the third party. In this way, even if the data is leaked, the configuration information of the full API will not be leaked, thereby ensuring the security of the data involved in the process of developing Android applications as much as possible, and thus improving the security of the data involved in the process of developing Android applications as much as possible.
[0076] As can be seen from the above description of “S302”, in response to the API call request sent by the third party, the server sends the corresponding API configuration information to the third party. That is, when the server determines that the API set corresponding to the third party includes the first API requested to be called by the third party, it can obtain the API configuration information corresponding to the third party. In view of this, Figure 4 As shown, the interface calling method provided in the embodiment of the present application may also include the following S401.
[0077] S401. The development device sends an AAR to the server, and correspondingly, the server receives the AAR from the development device.
[0078] The AAR includes an API set corresponding to the third party, or the AAR includes an API set corresponding to the third party and source code of each API in the API set corresponding to the third party.
[0079] It can be understood that since in the interface calling process, the API set corresponding to the third party can be used to subsequently verify whether the first API requested by the third party is legal, and the source code of each API in the API set corresponding to the third party can be used for the third-party configuration API, the development device provides AAR to the server, which can provide data preparation for subsequent interface calling processes.
[0080] In an optional implementation, the source code of each API in the API set corresponding to the third party includes the common code and the dedicated code of the API, and the common code of the API is the code shared by the API and other APIs.
[0081] It is understandable that in the relevant technology, when developing Android applications, the development device performs APK multi-channel packaging based on gradle scripts and product flavors, and each flavor can represent a specific APK channel configuration, wherein each specific APK channel configuration includes a specific SDK channel configuration. When the development device performs ADK multi-channel packaging based on gradle scripts and product flavors, it usually tries to share most of the source code in the SDK channel package, and only adds differential code to each flavor when necessary, that is, under normal circumstances, differential code is not added to each flavor. Therefore, when counting the APIs that can be called by third parties, the differences between the various APIs included in the SDK channel package cannot be clearly seen from each flavor.
[0082] However, in the interface calling method provided by this application, the source code of each API in the API set corresponding to the third party includes the common code and the dedicated code of the API, wherein the common code of the API is the code shared by the API and other APIs in the API set. In other words, the interface calling method recorded in this application not only transmits the common code for configuring the API, but also adds the dedicated code, so that the differences between different APIs can be displayed on the basis of ensuring the normal configuration of the API by the third party, so that the third party can distinguish different APIs more clearly.
[0083] Optionally, the AAR can be carried in the SDK channel package corresponding to the third party. Furthermore, in this case, the development device sends the SDK channel package corresponding to the third party to the server, and correspondingly, the server receives the SDK channel package corresponding to the third party from the development device. The SDK channel package corresponding to the third party includes the AAR.
[0084] Alternatively, the API call configuration information may also be carried in the SDK channel package corresponding to the third party. Furthermore, in this case, the development device sends the SDK channel package corresponding to the third party to the server, and correspondingly, the server receives the SDK channel package corresponding to the third party from the development device. The SDK channel package corresponding to the third party includes the API call configuration information.
[0085] In a possible implementation, before S401, the development device needs to generate an SDK channel package corresponding to the third party. The SDK tool and the third-party software development kit (SDK Third) tool can be deployed in the development device. The implementation process of the development device generating the SDK channel package corresponding to the third party through the SDK tool and the SDK Third tool can be: the development device copies the source code in the SDK tool to the SDK Third tool, and based on the source code in the SDK Third tool, determines the AAR in the SDK channel package corresponding to the third party. The development device copies the full API document in the SDK tool to the SDK Third tool, and determines the API document corresponding to the third party based on the full API document in the SDK Third tool. The API document corresponding to the third party includes the call configuration information of the API in the SDK channel package corresponding to the third party.
[0086] The following describes the interface configuration process.
[0087] like Figure 5 As shown, the “interface configuration process” includes S501 - S506 .
[0088] Further, optionally, if Figure 5 As shown, the development device copies the source code in the SDK tool to the SDK Third tool, and based on the source code in the SDK Third tool, determines the implementation process of the AAR in the SDK channel package corresponding to the third party, which may include the following S501 to S503:
[0089] S501. The development device determines an API that is allowed to be called by a third party based on the third party's calling requirements, and adds a corresponding third party channel annotation to the source code of the API that is allowed to be called by the third party.
[0090] For example, taking the API for turning on wireless fidelity (WIFI) included in the API allowed to be called by a third party as an example, the implementation process of the above development device adding the corresponding third-party channel annotation to the source code of the API allowed to be called by a third party may be: the development device adds @ProdToThird(channel="third-party name 1, third-party name 2") to the source code of the API for turning on WIFI (wifi on), and the source code of the API for turning on WIFI in the API allowed to be called by a third party may be:
[0091] / / Turn on WIFI
[0092] @ProdToThird(channel = "Third Party Name 1, Third Party Name 2")
[0093] public static final String WIFI_ON="wifi_on"
[0094] Further, taking the API for turning off wireless fidelity (wifi off) included in the API allowed to be called by a third party as an example, the implementation process of the above development device adding the corresponding third-party channel annotation to the source code of the API allowed to be called by a third party may be: the development device adds @ProdToThird(channel="third-party name 1, third-party name 2") to the source code of the API for turning off WIFI, and the source code of the API for turning off WIFI in the API allowed to be called by a third party may be:
[0095] / / Turn off WIFI
[0096] @ProdToThird(channel = "Third Party Name 1, Third Party Name 2")
[0097] public static final String WIFI_OFF="wifi_off"
[0098] Further, taking the example that the APIs that are not allowed to be called by third parties include an API for modifying password, in the SDK tool with the latest source code and the latest version number, the source code of the API for modifying password in the APIs that are not allowed to be called by third parties can be:
[0099] / / Change password
[0100] public static final String MODIFY_PASSWORD="modify_password"
[0101] Of course, the above is only an exemplary description of the API and API source code in the SDK tool. The SDK tool may also include other APIs, for example, an API for turning on the air conditioner. The source code of the API for turning on the air conditioner may also include other constant information. This application does not impose any restrictions on this.
[0102] S502: The development device updates the version number and source code in the SDK tool based on the source code of the API after adding the corresponding third-party channel annotation, so as to obtain the SDK tool with the latest source code and the latest version number.
[0103] It is understandable that timely updating of the version number and source code in the SDK tool by the development device can ensure that the code base in the SDK tool is up to date, thereby reducing the possibility of potential conflicts or errors in the subsequent compilation of the source code due to inconsistent source code.
[0104] S503: The development device starts to generate an SDK channel package corresponding to the third party in the SDK Third tool.
[0105] Optionally, the implementation process of the above S503 may be: the development device writes a corresponding script in the source code (src) in the SDK Third tool, and executes the corresponding script in the SDK Third tool to generate a corresponding SDK channel package for the third party.
[0106] Further, optionally, the development device executes the corresponding script in the SDK Third tool to generate an implementation process of the SDK channel package corresponding to the third party, which may include the following S5031 to S5033.
[0107] S5031. The development device executes a corresponding script in the SDK Third tool to copy the updated version number and updated source code in the SDK Third tool to the SDK Third tool.
[0108] Optionally, the implementation process of S5031 may be: the development device executes a corresponding script in the SDK Third tool to copy the updated source code and version number in the src / build.gradle directory in the SDK Third tool to the src / build.gradle directory in the SDK Third tool.
[0109] S5032. The development device modifies the source code in the SDK Third tool by executing a corresponding script in the SDK Third tool, thereby obtaining the modified source code in the SDK Third tool.
[0110] Optionally, the development device modifies the source code in the SDK Third tool to obtain the implementation process of the modified source code in the SDK Third tool as follows: the development device modifies the constants in the SDK Third tool by executing the corresponding script in the SDK Third tool. The development device deletes the Java class of the API that does not have the third-party channel annotation added in the source code of the SDK Third tool, and determines the retained source code in the SDK Third tool as the source code in the modified SDK Third tool, that is, the source code in the modified SDK Third tool includes the source code of the API that has the third-party channel annotation added.
[0111] For example, taking the constants in the SDK Third tool including SDK_CHANNEL as an example, the development device executes the corresponding script in the SDK Third tool to modify the constants in the SDK Third tool. The implementation process can be: the development device modifies the SDK_CHANNEL in the SDK Third tool to SDK_CHANNEL = "third-party name 1" based on the name of the third party. Of course, the above is only an exemplary description of the constants in the SDK Third tool. The SDK Third tool can also include other constants, and this application does not impose any restrictions on this.
[0112] It is understandable that the development device modifies the SDK_CHANNEL in the SDK Third tool to SDK_CHANNEL="Third Party Name 1" based on the name of the third party. The development device sends the modified SDK_CHANNEL="Third Party Name 1" to the server, and the server can verify the third party requesting to call the API based on the SDK_CHANNEL="Third Party Name 1". If the name of the corresponding third party is included in SDK_CHANNEL="Third Party Name 1", the server supports the third party requesting to call the API to call the corresponding API.
[0113] S5033. The development device compiles the source code in the modified SDK Third tool by executing the corresponding script in the SDK Third tool to generate an AAR.
[0114] Optionally, the implementation process of the development device generating and recording AAR can be: the development device can generate AAR in the directory of buid / outputs / in the SDK Third tool by executing the corresponding script in the SDK Third tool (that is, obtaining buid / outputs / aar), and record the generated AAR in the output directory in the SDK Third tool. In addition, the development device can also record the generated AAR in other directories that can be controlled by the development device, and the embodiments of the present application do not impose any restrictions on this.
[0115] Further, optionally, the development device may name the above AAR. The development device may name the AAR based on the name of a third party or the name of an API that the third party is allowed to call. This application does not impose any restrictions on this.
[0116] Exemplarily, the corresponding script may be in the form of mk_sdk_for_third_py. Of course, the script may also be in other forms, and this application does not impose any limitation on this.
[0117] It is understandable that in the embodiments provided in this application, the third-party SDK channel package generated by the SDK Third tool is not packaged into the APK file of the Android application. The development device uses the SDK Third tool to package the SDK channel package corresponding to the third party, and does not directly use the SDK tool to package the SDK channel package corresponding to the third party. Therefore, the development device can quickly package multiple SDK channel packages corresponding to third parties in the SDK Third tool, which improves the efficiency of the development device in generating SDK channel packages corresponding to third parties.
[0118] Further, optionally, the development device copies the full API document in the SDK tool to the SDK Third tool, and the implementation process of determining the API document corresponding to the third party based on the full API document in the SDK Third tool may include the following S504 to S506:
[0119] S504, the development device copies the full API document in the SDK tool to the SDK Third tool.
[0120] Optionally, the development device can copy the full API documentation in the SDK tool to the document (document word binary file format, doc) directory in the SDK Third tool. The development device can also copy the full API documentation in the SDK tool to other directories in the SDK Third tool. This application does not impose any restrictions on this.
[0121] S505. The development device determines the API included in the source code in the modified SDK Third tool by executing the corresponding script in the SDK Third tool, and records the determined API included in the source code in the modified SDK Third tool in the target document.
[0122] Optionally, the target document may be recorded in a directory of the SDK Third tool, or in other directories that the development device can control. The present application embodiment does not impose any limitation on this.
[0123] Exemplarily, taking the example that the API included in the source code of the modified SDK Third tool includes an API for turning on WIFI and an API for turning off WIFI, the implementation process of the above-mentioned development device recording the API included in the source code of the modified SDK Third tool in the target document can be: the development device records the API for turning on WIFI and the API for turning off WIFI in the target document.
[0124] S506. The development device can determine the corresponding API document of the third party in the full API document in the SDK Third tool based on the API recorded in the above target document by executing the corresponding script in the SDK Third tool.
[0125] The API document corresponding to the third party may include API call configuration information corresponding to the third party.
[0126] Optionally, the implementation process of S506 can be: the development device executes the corresponding script in the SDK Third tool, and based on the API recorded in the target document, scans the full API document in the SDK Third tool. The development device deletes the call configuration information of the API in the full API document in the SDK Third tool that is not recorded in the target document, and determines the call configuration information of the API retained in the full API document in the SDK Third tool as the corresponding API document of the third party.
[0127] In some possible implementations, the development device may record the obtained API document corresponding to the third party in the output directory of the SDK Third tool to which the above AAR belongs.
[0128] It can be understood that in the interface calling method provided by the present application, the development device automatically generates the API document corresponding to the third party based on the full API document in the SDK Third tool by executing the corresponding script in the SDK Third tool. The API document corresponding to the third party includes the calling configuration information of the API in the SDK channel package corresponding to the third party. Compared with the prior art, which requires manual modification of the API documents in the SDK channel packages corresponding to different third parties for different third parties, the interface configuration process included in the interface calling method provided in the embodiment of the present application improves the generation efficiency of the SDK channel package corresponding to the third party.
[0129] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to realize the above functions, the interface calling device or electronic device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0130] The embodiment of the present application can exemplarily divide the functional modules of the API calling device or electronic device according to the above method. For example, the interface calling device or electronic device may include various functional modules corresponding to the various functional divisions, or two or more functions may be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0131] Figure 6 is a block diagram of an interface calling device according to an exemplary embodiment. Figure 6 The interface calling device 60 includes: a communication unit 601 and a processing unit 602.
[0132] When the interface calling device 60 is used to show the structure of the server:
[0133] The processing unit 602 is used to instruct the communication unit 601 to receive an application programming interface API call request from a third party, where the interface call request is used to request to call a first API;
[0134] The processing unit 602 is also used to instruct the communication unit 601 to send API configuration information to the third party when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes the API allowed to be called by the third party, and the API configuration information includes configuration information of the API allowed to be called by the third party.
[0135] In a possible implementation, the API configuration information includes API source code and API call configuration information.
[0136] In a possible implementation, the processing unit 602 is also used to instruct the communication unit 601 to receive an Android library project archive file AAR from a development device, where the AAR includes an API set corresponding to a third party, or the AAR includes an API set corresponding to a third party and the source code of each API in the API set corresponding to the third party.
[0137] In a possible implementation, the source code of each API in the API set corresponding to the third party includes the common code and the dedicated code of the API, and the common code of the API is the code shared by the API and other APIs in the API set.
[0138] When the interface calling means 60 is used to display the structure of a third party:
[0139] The processing unit 602 is used to instruct the communication unit 601 to send an API call request to the server, where the API call request is used to request to call a first API;
[0140] The processing unit 602 is also used to instruct the communication unit 601 to receive API configuration information from the server, where the API configuration information is triggered to be sent when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes an API allowed to be called by the third party, and the API configuration information includes configuration information of the API allowed to be called by the third party.
[0141] In a possible implementation, the API configuration information includes API source code and API call configuration information.
[0142] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0143] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions. The above instructions can be executed by the processor 201 of the interface calling device 20 to implement the method in the above embodiment.
[0144] In actual implementation, Figure 6 The functions of the communication unit 601 and the processing unit 602 can be obtained by Figure 2 The processor 201 in the embodiment calls the computer program stored in the memory 204 to implement. The specific execution process can refer to the description of the method part in the above embodiment, which will not be repeated here.
[0145] Optionally, the computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0146] In an exemplary embodiment, the present application also provides a computer program product including one or more instructions, and the one or more instructions can be executed by the processor 201 of the electronic device to complete the method in the above embodiment.
[0147] It should be noted that when the instructions in the above-mentioned computer-readable storage medium or one or more instructions in the computer program product are executed by the processor of the electronic device, the various processes of the above-mentioned method embodiment are implemented, and the same technical effect as the above-mentioned method can be achieved. To avoid repetition, they will not be repeated here.
[0148] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0149] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0150] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0151] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0152] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the full classification part or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute the full classification part or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or CD and other media that can store program code.
[0153] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An interface calling method, characterized in that: Applied to the server, including: Receiving an application programming interface (API) call request from a third party, wherein the API call request is used to request to call a first API; In a case where the API set corresponding to the third party includes the first API, API configuration information is sent to the third party, wherein the API set corresponding to the third party includes an API that the third party is allowed to call, and the API configuration information includes configuration information of the API that the third party is allowed to call.
2. The method according to claim 1, characterized in that The API configuration information includes the source code of the API and the calling configuration information of the API.
3. The method according to claim 1 or 2, characterized in that: Before receiving the API call request from the third party, the method further includes: An Android library project archive file AAR is received from a development device, where the AAR includes the API set corresponding to the third party, or the AAR includes the API set corresponding to the third party and source code of each API in the API set corresponding to the third party.
4. The method according to claim 3, characterized in that The source code of each API in the API set corresponding to the third party includes the common code and the dedicated code of the API, and the common code of the API is the code shared by the API and other APIs in the API set.
5. An interface calling method, characterized in that: For third parties, including: Sending an API call request to the server, where the API call request is used to request calling a first API; Receive API configuration information from the server, wherein the API configuration information is triggered to be sent when the first API is included in the API set corresponding to the third party, wherein the API set corresponding to the third party includes an API that the third party is allowed to call, and the API configuration information includes configuration information of the API that the third party is allowed to call.
6. The method according to claim 5, characterized in that The API configuration information includes the source code of the API and the calling configuration information of the API.
7. An interface calling device, characterized in that: The interface calling device comprises: a processing unit and a communication unit; The processing unit is used to instruct the communication unit to receive an application programming interface API call request from a third party, where the API call request is used to request to call a first API; The processing unit is also used to instruct the communication unit to send API configuration information to the third party when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes an API that the third party is allowed to call, and the API configuration information includes configuration information of the API that the third party is allowed to call.
8. An interface calling device, characterized in that: The interface calling device comprises: a processing unit and a communication unit; The processing unit is used to instruct the communication unit to send an API call request to the server, where the API call request is used to request to call a first API; The processing unit is also used to instruct the communication unit to receive API configuration information from the server, and the API configuration information is triggered to be sent when the API set corresponding to the third party includes the first API, wherein the API set corresponding to the third party includes an API allowed to be called by the third party, and the API configuration information includes configuration information of the API allowed to be called by the third party.
9. An interface calling device, characterized in that: include: A processor and a communication interface; the communication interface is coupled to the processor, and the processor is used to run a computer program or instruction to implement the interface calling method as described in any one of claims 1-6.
10. A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, characterized in that: When a computer executes the instruction, the computer executes the interface calling method described in any one of claims 1 to 6.