CN110221880A - Application programming interface calling method, device, equipment and medium - Google Patents

Application programming interface calling method, device, equipment and medium Download PDF

Info

Publication number
CN110221880A
CN110221880A CN201910487094.2A CN201910487094A CN110221880A CN 110221880 A CN110221880 A CN 110221880A CN 201910487094 A CN201910487094 A CN 201910487094A CN 110221880 A CN110221880 A CN 110221880A
Authority
CN
China
Prior art keywords
api
code
environment information
calling code
current operating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910487094.2A
Other languages
Chinese (zh)
Other versions
CN110221880B (en
Inventor
徐朋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Internet Security Software Co Ltd
Original Assignee
Beijing Kingsoft Internet Security Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201910487094.2A priority Critical patent/CN110221880B/en
Publication of CN110221880A publication Critical patent/CN110221880A/en
Application granted granted Critical
Publication of CN110221880B publication Critical patent/CN110221880B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention provides a method, a device, a terminal device, a server device and a storage medium for calling an application programming interface, wherein the method comprises the following steps: in the starting process, acquiring the current operating environment information of the terminal equipment; acquiring calling codes of all APIs corresponding to the current operating environment information; when the application program runs to a preset position of an API to be called, determining a calling code of a target API corresponding to the preset position from calling codes of all APIs; wherein the preset positions correspond to the APIs one by one; and executing the calling code of the target API. And adopting the application program of the same version, and adding a preset position for calling the API in the application program of the version so as to execute a calling code of the target API corresponding to the preset position when the application program runs to the preset position, thereby completing the calling operation of the target API. Accordingly, the compatibility of the application program can be improved.

Description

Application programming interface call method, device, equipment and medium
Technical field
The present invention relates to application program (Application, APP) running technology fields, apply journey more particularly to a kind of Sequence programming interface (Application Programming Interface, API) call method, device, terminal device, service End equipment and storage medium.
Background technique
With the continuous development of computer technology, the type of application program is also more and more, and application program is by calling API Realize some specific functions.
For a kind of application program, since operating system there are many versions, to adapt to different operating system versions, need Develop the application program of different editions.Therefore, application compatibility is lower.
Summary of the invention
The embodiment of the present invention be designed to provide a kind of application programming interface call method, device, terminal device, Server device and storage medium, to improve the compatibility of application program.Specific technical solution is as follows:
In a first aspect, being applied to terminal the embodiment of the invention provides a kind of application programming interface API Calls method Application client in equipment, which comprises
In the application client start-up course, the current operating environment information of the terminal device is obtained;
Obtain the calling code of each API corresponding with the current operating environment information;
When application program is run to the predeterminated position of API to be called, from the calling code of each API, determine The calling code of target API corresponding with the predeterminated position;Wherein, predeterminated position and AP I are corresponded;
Execute the calling code of the target API.
Further, the step of calling code for obtaining each API corresponding with the current operating environment information, Include:
The current operating environment information is sent to the server device connecting with the terminal equipment in communication, so that described In the calling code library that server device judgement prestores, if there is each API corresponding with the current operating environment information Calling code;Calling code comprising each API for different running environment in the calling code library;If it exists, then The calling code of each API corresponding with the current operating environment information is returned to the application client;
Receive the calling generation for each API corresponding with the current operating environment information that the server device returns Code.
Further, it is located in same calling code packet for the calling code of each API of same running environment;It is described It include running environment information in code packet;
The step that the current operating environment information is sent to the server device connecting with the terminal equipment in communication Suddenly, comprising:
According to the running environment information for including in the code packet, judge to whether there is and the current fortune in local cache The calling code of the corresponding each API of row environmental information;
If it does not exist, then the current operating environment letter is sent to the server device connecting with the terminal equipment in communication Breath.
Further, described when application program is run to the predeterminated position of API to be called, from each API's Before the step of calling in code, determining the calling code of target API corresponding with the predeterminated position, further includes:
If there is the calling code of each API corresponding with the current operating environment information in local cache, from this The calling code of each API corresponding with the current operating environment information is obtained in ground caching.
Further, the current operating environment information includes the version information of operating system;
The method also includes:
If receive the server device return is not present each API corresponding with the current operating environment information Calling code notice, then when application program is run to the predeterminated position of API to be called, what is prestored from local cache is each In the original call code of a API, the original call code of target API corresponding with the predeterminated position is determined, it is described each The original call code of API is the calling code of each API corresponding with the original version of the operating system;
Execute the original call code of the target API.
Second aspect, the embodiment of the invention provides a kind of application programming interface API Calls methods, are applied to and end The server device of end equipment communication connection, which comprises
Receive the current operating environment letter for the terminal device that the application client in the terminal device is sent Breath;The current operating environment information be the application client during startup, obtain working as the terminal device It is sent after preceding running environment information;
Judge in the calling code library prestored, if having each API's corresponding with the current operating environment information Call code;Calling code comprising each API for different running environment in the calling code library;
If it exists, Xiang Suoshu application client sends each API's corresponding with the current operating environment information Code is called, so that the application client receives each API's corresponding with the current operating environment information Code is called, and when application program is run to the predeterminated position of API to be called, from the calling code of each API, really The calling code of fixed target API corresponding with the predeterminated position;Execute the calling code of the target API;Wherein, position is preset It sets and is corresponded with AP I.
Further, the method also includes:
If in the calling code library prestored, there is no each API's corresponding with the current operating environment information Code is called, then is sent to the application client and each API corresponding with the current operating environment information is not present Calling code notice it is slow from the local of terminal device so that when application program is run to the predeterminated position of API to be called In the original call code for depositing each API prestored, the original call generation of target API corresponding with the predeterminated position is determined Code;Execute the original call code of the target API;The original call code of each API be and the operating system The calling code of the corresponding each API of original version.
The third aspect, the embodiment of the invention provides a kind of application programming interface API Calls devices, are applied to terminal Application client in equipment, described device include:
Running environment data obtaining module, for obtaining the terminal in the application client start-up course The current operating environment information of equipment;
Code obtaining module is called, for obtaining the calling generation of each API corresponding with the current operating environment information Code;
Code determining module is called, for when application program is run to the predeterminated position of API to be called, from described each In the calling code of API, the calling code of target API corresponding with the predeterminated position is determined;Wherein, predeterminated position and AP I It corresponds;
Code execution module is called, for executing the calling code of the target API.
Further, the calling Code obtaining module, comprising: running environment information sending submodule and calling code connect Receive submodule;
The running environment information sending submodule, for being sent out to the server device being connect with the terminal equipment in communication The current operating environment information is sent, so that in the calling code library that prestores of server device judgement, if exist and institute State the calling code of the corresponding each API of current operating environment information;Comprising being directed to different operation rings in the calling code library The calling code of each API in border;If it exists, then it is returned and the current operating environment information to the application client The calling code of corresponding each API;
The calling code receiving submodule is returning with the current operating environment for receiving the server device The calling code of the corresponding each API of information.
Further, it is located in same calling code packet for the calling code of each API of same running environment;It is described It include running environment information in code packet;
The running environment information sending submodule, comprising: judging unit and running environment information transmitting unit;
The judging unit is in local cache for judging according to the running environment information for including in the code packet The no calling code that there is each API corresponding with the current operating environment information;
The running environment information transmitting unit, for corresponding each with the current operating environment information if it does not exist The calling code of API then sends the current operating environment information to the server device connecting with the terminal equipment in communication.
Further, the calling Code obtaining module, further includes: call Code obtaining submodule;
The calling Code obtaining submodule, for running in the application program of working as to the predeterminated position of API to be called When, from the calling code of each API, before the calling code for determining target API corresponding with the predeterminated position, if There is the calling code of each API corresponding with the current operating environment information in local cache, is then obtained from local cache The calling code of each API corresponding with the current operating environment information is taken, and triggers the calling code determining module.
Further, the current operating environment information includes the version information of operating system;
The calling code determining module is worked as if being also used to receive being not present for server device return with described The notice of the calling code of the corresponding each API of preceding running environment information, then when application program run it is default to API to be called When position, from the original call code of each API prestored in local cache, target corresponding with the predeterminated position is determined The original call code of API, the original call code of each API are corresponding with the original version of the operating system each The calling code of a API;
The calling code execution module, is also used to the original in determination target API corresponding with the predeterminated position Begin after calling code, executes the original call code of the target API.
Fourth aspect, the embodiment of the invention provides a kind of application programming interface API Calls devices, are applied to and end The server device of end equipment communication connection, described device include:
Running environment information receiving module, for receiving described in the transmission of the application client in the terminal device The current operating environment information of terminal device;The current operating environment information is the application client in start-up course In, obtain the current operating environment information transmission later of the terminal device;
Judgment module, in the calling code library for judging to prestore, if exist and the current operating environment information pair The calling code of each API answered;Calling generation comprising each API for different running environment in the calling code library Code;
Code sending module is called, if existing and the current operating environment information pair in the calling code library for prestoring The calling code of each API answered, Xiang Suoshu application client send corresponding with the current operating environment information each The calling code of a API, so that application client reception is described corresponding with the current operating environment information each The calling code of a API, and when application program is run to the predeterminated position of API to be called, from the calling generation of each API In code, the calling code of target API corresponding with the predeterminated position is determined;Execute the calling code of the target API;Its In, predeterminated position and AP I are corresponded.
Further, described device further include:
Sending module is notified, if there is no believe with the current operating environment in the calling code library prestored The calling code of corresponding each API is ceased, then sends and is not present and the current operating environment to the application client The notice of the calling code of the corresponding each API of information, so that when application program is run to the predeterminated position of API to be called, From the original call code of each API prestored in the local cache of terminal device, determination is corresponding with the predeterminated position The original call code of target API;Execute the original call code of the target API;The original call code of each API For the calling code of each API corresponding with the original version of the operating system.
5th aspect, the embodiment of the invention provides a kind of terminal device, including processor, communication interface, memory and Communication bus, wherein processor, communication interface, memory complete mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes any application program in above-mentioned first aspect The step of programming interface API Calls method.
6th aspect, the embodiment of the invention provides a kind of server devices, including processor, communication interface, memory And communication bus, wherein processor, communication interface, memory complete mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes any application program in above-mentioned second aspect The step of programming interface API Calls method.
7th aspect, it is described computer-readable to deposit the embodiment of the invention also provides a kind of computer readable storage medium Computer program is stored in storage media, when run on a computer, so that computer executes any of the above-described application program The step of programming interface API Calls method.
Eighth aspect, the embodiment of the invention also provides a kind of computer program products comprising instruction, when it is being calculated When being run on machine, so that the step of computer executes any of the above-described application programming interface API Calls method.
A kind of application programming interface API Calls method, apparatus provided in an embodiment of the present invention, terminal device, service End equipment and storage medium, the application client in terminal device obtain working as the terminal device during startup Preceding running environment information;Obtain the calling code of each API corresponding with the current operating environment information;When application program is transported When row will extremely call the predeterminated position of API, from the calling code of each API, determination is corresponding with the predeterminated position The calling code of target API;Wherein, predeterminated position and AP I are corresponded;Execute the calling code of the target API.This hair In bright embodiment, without being directed to different running environment, the application program of different editions is developed, but uses answering for same version With program, increase the predeterminated position that call API in the application program of the version, so as to preset when application program is run to this When position, the calling code of target API corresponding with predeterminated position is executed, to complete the call operation of target API.Therefore, The compatibility of application program can be improved.
Certainly, implement any of the products of the present invention or method it is not absolutely required at the same reach all the above excellent Point.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with It obtains other drawings based on these drawings.
Fig. 1 is the application client that API Calls method provided by one embodiment of the present invention is applied in terminal device A kind of flow diagram at end;
Fig. 2 is the application client that API Calls method provided by one embodiment of the present invention is applied in terminal device Another flow diagram at end;
Fig. 3 is that API Calls method provided by one embodiment of the present invention is applied to the service connecting with terminal equipment in communication A kind of flow diagram of end equipment;
Fig. 4 is a kind of interaction flow schematic diagram of API Calls method provided in an embodiment of the present invention;
Fig. 5 is a kind of structural schematic diagram of API Calls device provided in an embodiment of the present invention;
Fig. 6 is the structural schematic diagram of another API Calls device provided in an embodiment of the present invention;
Fig. 7 is a kind of structural schematic diagram of terminal device provided in an embodiment of the present invention;
Fig. 8 is a kind of structural schematic diagram of server device provided in an embodiment of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
In order to improve the compatibility of application program, the embodiment of the invention provides a kind of application programming interface API tune With method, apparatus, terminal device and server device.
Referring to Fig. 1, Fig. 1 is the application that API Calls method provided by one embodiment of the present invention is applied in terminal device A kind of flow diagram of programmatic client, specifically comprises the following steps:
Step 101, in application client start-up course, the current operating environment information of terminal device is obtained.
The current operating environment information of terminal device can be the information of the operating system classification in characterization terminal device, example It such as, may include: the manufacturer's information, operating system classification information and the version information of operating system etc. of terminal device.
Step 102, the calling code of each API corresponding with current operating environment information is obtained.
For Android system, different classes of and version operating system, i.e., different running environment, API Calls side There is some difference for formula, therefore, in the embodiment of the present invention, can be directed to different running environment information, write in advance different API Calls code, before carrying out API Calls, the tune of each API corresponding with current operating environment information available first Use code.
Specifically, the calling code write can be packaged as to JAR (Java Archive, JAVA archive file) lattice Packed calling code is stored in the server device connecting with terminal equipment in communication by formula, and not according to running environment It is disconnected to update, calling code corresponding with the running environment updated is replenished in time.
When application program launching, each API corresponding with current operating environment information can be obtained from server device Calling code;Previously stored believing with current operating environment from server device acquisition can also be obtained from local cache Cease the calling code of corresponding each API.
Step 103, when application program is run to the predeterminated position of API to be called, from the calling code of each API, Determine the calling code of target API corresponding with predeterminated position.
Wherein, predeterminated position and AP I are corresponded.
Step 104, the calling code of performance objective API.
By the above embodiments as it can be seen that in embodiments of the present invention, without being directed to different running environment, developing different versions This application program, but use the application program of same version, setting will call that API's is pre- in the application program of the version If position, so as to execute the calling generation of target API corresponding with predeterminated position when application program is run to the predeterminated position Code, to complete the call operation of target API.It is thus possible to improve the compatibility of application program.
Referring to fig. 2, Fig. 2 is the application that API Calls method provided by one embodiment of the present invention is applied in terminal device Another flow diagram of programmatic client, specific steps include:
Step 201, in application client start-up course, the current operating environment information of terminal device is obtained.
The current operating environment information of terminal device can be the information of the operating system classification in characterization terminal device, example It such as, may include: the manufacturer's information, operating system classification information and the version information of operating system etc. of terminal device.
Step 202, according to the running environment information for including in code packet, judge to transport in local cache with the presence or absence of with current The calling code of the corresponding each API of row environmental information.If there is no corresponding with current operating environment information in local cache The calling code of each API executes step 203;If there is each API corresponding with current operating environment information in local cache Calling code, execute step 205.
Compared with operating system when the starting of application program last time in terminal device, operating system is possible to when this starts It changes, it is also possible to and have not been changed, for example, if user rises operating system after the starting of application program last time Grade, hereafter, when application program is again started up, operating system then changes, i.e., running environment changes;If user is not to behaviour Upgraded as system, then running environment is constant.
If the corresponding running environment of 2 start-up courses of application program does not change, when due to the 1st starting, application Program has obtained the calling code of each API corresponding with running environment, exists in local cache corresponding with running environment Each API calling code, therefore, in the 2nd starting, application program need to only be obtained from local cache and running environment The calling code of corresponding each API;If running environment is changed, application program needs are set from server-side again The standby calling code for obtaining each API corresponding with current operating environment, so as to subsequent use.
Specifically, can be located in same calling code packet for the calling code of each API of same running environment;And It include running environment information in code packet.Therefore, after application client starting, can include according in code packet Running environment information judges the calling code that whether there is each API corresponding with current operating environment information in local cache.
Step 203, current operating environment information is sent to the server device connecting with terminal equipment in communication.
Step 204, the calling generation for each API corresponding with current operating environment information that server device returns is received Code.Later, step 206 is executed.
Specifically, calling code library can be pre-created in the server device connecting with terminal equipment in communication, the tune There are the different API Calls codes write in advance for different running environment information with storage in code library, as shown in Table 1, Running environment information different in code library is called to correspond to different API Calls codes:
Table one
Server device is after receiving current operating environment information, it can be determined that in the calling code library prestored, is The no calling code that there is each API corresponding with current operating environment information;Wherein, it calls in code library comprising for difference The calling code of each API of running environment;If it exists, then it is returned and current operating environment information pair to application client The calling code of each API answered.
Step 205, the calling code of each API corresponding with current operating environment information is obtained from local cache.
Step 206, when application program is run to the predeterminated position of API to be called, from the calling code of each API, Determine the calling code of target API corresponding with predeterminated position.
Wherein, predeterminated position and AP I are corresponded.
Step 207, the calling code of performance objective API.
Below with a specific example, embodiment illustrated in fig. 2 is illustrated:
Such as: assuming that: the current operating environment of the terminal device where application program are as follows: xm=a1, xui=b1, Android=6.0;Target API is priority assignation page API;
Application client during startup, obtains current operating environment information: xm=a1, xui=b1, Android=6.0, and first judge in local cache with the presence or absence of each API's corresponding with above-mentioned current operating environment information Code is called, if it does not exist, then sends above-mentioned current operating environment information to the server device connecting with terminal equipment in communication: Xm=a1, xui=b1, android=6.0, so that server device return is corresponding with above-mentioned current operating environment information each Calling code-calling code 1 of a API, when application program is run to the predeterminated position of priority assignation page API to be called: xm_ When xui_android_permission (), from calling in code 1, defines the competence and the calling code of page API is set, and hold The calling code of row priority assignation page API, with the priority assignation page of display terminal.
In another embodiment of the invention, if prestoring for server device is called in code library, there is no transport with current The calling code of the corresponding each API of row environmental information, then server device is sent to application client is not present and works as The notice of the calling code of the corresponding each API of preceding running environment information, when application program is run to the default position of API to be called When setting, then from the original call code of each API prestored in local cache, target API corresponding with predeterminated position is determined Original call code, and the original call code of performance objective API.Wherein, the original call code of each API is and operation The calling code of the corresponding each API of the original version of system.In fact, application client can load during startup The original call code of each API, since above-mentioned original call code is the included original call code of system, this reality It applies in example, if application client receives the calling code there is no each API corresponding with current operating environment information Notice, then the original call code of performance objective API, to guarantee that application client continues to run.
By above-mentioned embodiment shown in Fig. 2 as it can be seen that the application program of same version can be used, in the application journey of the version The predeterminated position of API will be called by increasing in sequence, so as to execute and predeterminated position pair when application program is run to the predeterminated position The calling code of the target API answered, to complete the call operation of target API.It is thus possible to improve the compatibility of application program Property.Meanwhile first judging the calling code that whether there is each API corresponding with current operating environment in local cache, work as presence The calling code of each API corresponding with current operating environment, then directly from local acquisition, without again from server device It obtains, therefore, bandwidth resources can be saved.
Referring to Fig. 3, Fig. 3 is that API Calls method provided in an embodiment of the present invention is applied to connect with terminal equipment in communication A kind of flow diagram of server device, the specific steps are as follows:
Step 301, the current operating environment letter for the terminal device that the application client in receiving terminal apparatus is sent Breath.
Wherein, current operating environment information be application client during startup, obtain the current of terminal device It is sent after running environment information.
Step 302, judge in the calling code library prestored, if exist corresponding with current operating environment information each The calling code of API.
Wherein, the calling code comprising each API for different running environment in code library is called.
Step 303, and if it exists, send each API's corresponding with current operating environment information to application client Code is called, so that the calling code of application client reception each API corresponding with current operating environment information, and When application program is run to the predeterminated position of API to be called, from the calling code of each API, determination is corresponding with predeterminated position Target API calling code;The calling code of performance objective API.
Wherein, predeterminated position and AP I are corresponded.
In above-mentioned embodiment shown in Fig. 3, server device is receiving current operating environment information, and judges to call After the calling code that there is each API corresponding with current operating environment information in code library, return and current operating environment The calling code of the corresponding each API of information, so that application client runs presetting to API to be called in application program When position, from the calling code of each API, the calling code of target API corresponding with predeterminated position is determined;Performance objective The calling code of API.In the embodiment, without being directed to different running environment, the application program of different editions is developed, but is adopted With the application program of same version, increase the predeterminated position that call API in the application program of the version, so that when applying journey When sort run to the predeterminated position, the calling code of target API corresponding with predeterminated position is executed, to complete target API's Call operation.It is thus possible to improve the compatibility of application program.
Referring to fig. 4, Fig. 4 is a kind of interaction flow schematic diagram of API Calls method provided in an embodiment of the present invention, specific to wrap Include following steps:
Step 401, the application client in terminal device during startup, obtains the current operation of terminal device Environmental information.
The current operating environment information of terminal device can be the information of the operating system classification in characterization terminal device, example It such as, may include: the manufacturer's information, operating system classification information and the version information of operating system etc. of terminal device.
Step 402, application client is according to the running environment information for including in code packet, judge be in local cache The no calling code that there is each API corresponding with current operating environment information.If so, executing step 403;If it is not, executing step Rapid 404.
Step 403, application client obtains each API corresponding with current operating environment information from local cache Calling code.Later, step 407 is executed.
Step 404, application client sends current operating environment information to server device.
Step 405, in the calling code library that server device judgement prestores, if exist and current operating environment information pair The calling code of each API answered.If so, executing step 406;If it is not, executing step 409.
Step 406, server device sends each API corresponding with current operating environment information to application client Calling code.
Step 407, when application program is run to the predeterminated position of API to be called, from the calling code of each API, Determine the calling code of target API corresponding with predeterminated position.
Step 408, the calling code of application client performance objective API.Later, API Calls are completed.
Step 409, there is no corresponding with current operating environment information to application client transmission for server device The notice of the calling code of each API.
Step 410, when application program is run to the predeterminated position of API to be called, what is prestored from local cache is each In the original call code of API, the original call code of target API corresponding with predeterminated position is determined.
Wherein, the original call code of each API is the calling generation of each API corresponding with the original version of operating system Code.
Step 411, the original call code of performance objective API.
In the embodiment shown in fig. 4, the application program that can use same version, increases in the application program of the version Add the predeterminated position of API to be called, so as to execute mesh corresponding with predeterminated position when application program is run to the predeterminated position The calling code for marking API, to complete the call operation of target API.It is thus possible to improve the compatibility of application program.
Based on the same inventive concept, the API Calls method provided according to that above embodiment of the present invention, correspondingly, the present invention Embodiment additionally provides a kind of API Calls device, applied to the application client in terminal device;The structure of the device is shown It is intended to as shown in Figure 5, comprising:
Running environment data obtaining module 501, for obtaining terminal device in application client start-up course Current operating environment information;
Code obtaining module 502 is called, for obtaining the calling generation of each API corresponding with current operating environment information Code;
Code determining module 503 is called, for when application program is run to the predeterminated position of API to be called, from each In the calling code of API, the calling code of target API corresponding with predeterminated position is determined;Wherein, predeterminated position and AP I be one by one It is corresponding;
Call code execution module 504, the calling code for performance objective API.
Further, Code obtaining module 502 is called, comprising: running environment information sending submodule and calling code connect Receive submodule;
Running environment information sending submodule, for sending current fortune to the server device connecting with terminal equipment in communication Row environmental information, so that in the calling code library that server device judgement prestores, if exist and current operating environment information pair The calling code of each API answered;Call the calling code comprising each API for different running environment in code library;If In the presence of then to the calling code of application client return each API corresponding with current operating environment information;
Code receiving submodule is called, for receiving the corresponding with current operating environment information each of server device return The calling code of a API.
Further, it is located in same calling code packet for the calling code of each API of same running environment;Code It include running environment information in packet;
Running environment information sending submodule, comprising: judging unit and running environment information transmitting unit;
Judging unit, for according to the running environment information for including in code packet, judge in local cache with the presence or absence of with The calling code of the corresponding each API of current operating environment information;
Running environment information transmitting unit, the tune for each API corresponding with current operating environment information if it does not exist With code, then current operating environment information is sent to the server device connecting with terminal equipment in communication.
Further, Code obtaining module 502 is called, further includes: call Code obtaining submodule;
Code obtaining submodule is called, for when application program is run to the predeterminated position of API to be called, from each In the calling code of API, before the calling code for determining target API corresponding with predeterminated position, if in local cache in the presence of with The calling code of the corresponding each API of current operating environment information then obtains and current operating environment information from local cache The calling code of corresponding each API, and trigger and call code determining module.
Further, current operating environment information includes the version information of operating system;
Code determining module 503 is called, if being also used to receive being not present and current operation ring for server device return The notice of the calling code of the corresponding each API of border information, then when application program is run to the predeterminated position of API to be called, From the original call code of each API prestored in local cache, the original tune of target API corresponding with predeterminated position is determined With code, the original call code of each API is the calling code of each API corresponding with the original version of operating system;
Code execution module 504 is called, is also used in the original call code for determining target API corresponding with predeterminated position Later, the original call code of performance objective API.
In embodiment illustrated in fig. 5 of the present invention, without being directed to different running environment, the application journey of different editions is developed Sequence, but the application program of same version is used, increase the predeterminated position that call API in the application program of the version, with Make the calling code of target API corresponding with predeterminated position to be executed, to complete when application program is run to the predeterminated position The call operation of target API.It is thus possible to improve the compatibility of application program.
Based on the same inventive concept, the API Calls method provided according to that above embodiment of the present invention, correspondingly, the present invention Embodiment additionally provides a kind of API Calls device, applied to the server device connecting with terminal equipment in communication;The knot of the device Structure schematic diagram is as shown in Figure 6, comprising:
Running environment information receiving module 601, the terminal sent for the application client in receiving terminal apparatus The current operating environment information of equipment;Current operating environment information be application client during startup, obtain terminal It is sent after the current operating environment information of equipment;
Judgment module 602, in the calling code library for judging to prestore, if exist corresponding with current operating environment information Each API calling code;Call the calling code comprising each API for different running environment in code library;
Code sending module 603 is called, if existing and current operating environment information pair in the calling code library for prestoring The calling code of each API answered sends the tune of each API corresponding with current operating environment information to application client With code, so that application client receives the calling code of each API corresponding with current operating environment information, and answering When being run with program to the predeterminated position of API to be called, from the calling code of each API, determination is corresponding with predeterminated position The calling code of target API;The calling code of performance objective API;Wherein, predeterminated position and AP I are corresponded.
Further, device further include:
Sending module is notified, if in the calling code library for prestoring, there is no corresponding with current operating environment information The calling code of each API then sends to application client and each API corresponding with current operating environment information is not present Calling code notice it is slow from the local of terminal device so that when application program is run to the predeterminated position of API to be called In the original call code for depositing each API prestored, the original call code of target API corresponding with predeterminated position is determined; The original call code of performance objective API;The original call code of each API is corresponding with the original version of operating system each The calling code of a API.
In embodiment illustrated in fig. 6 of the present invention, server device receives currently in running environment information receiving module 601 Running environment information, judgment module 602, which is judged to call, has each API corresponding with current operating environment information in code library Calling code after, call code sending module 603 to return to the calling generation of each API corresponding with current operating environment information Code, so that application client is when application program is run to the predeterminated position of API to be called, from the calling generation of each API In code, the calling code of target API corresponding with predeterminated position is determined;The calling code of performance objective API.In the embodiment, Without developing the application program of different editions for different running environment, but the application program of same version is used, at this The predeterminated position of API will be called by increasing in the application program of version, so as to execute when application program is run to the predeterminated position The calling code of target API corresponding with predeterminated position, to complete the call operation of target API.It is thus possible to improve using The compatibility of program.
The embodiment of the invention also provides a kind of terminal device, as shown in fig. 7, comprises processor 701, communication interface 702, Memory 703 and communication bus 704, wherein processor 701, communication interface 702, memory 703 are complete by communication bus 704 At mutual communication,
Memory 703, for storing computer program;
Processor 701 when for executing the program stored on memory 703, realizes following steps:
In application client start-up course, the current operating environment information of terminal device is obtained;
Obtain the calling code of each API corresponding with current operating environment information;
When application program is run to the predeterminated position of API to be called, from the calling code of each API, it is determining with it is pre- If the calling code of the corresponding target API in position;Wherein, predeterminated position and AP I are corresponded;
The calling code of performance objective API.
Further, can also include above-mentioned API Calls method provided in an embodiment of the present invention in other process flows, It is no longer described in detail herein.
The embodiment of the invention also provides a kind of server device, which connect with terminal equipment in communication, such as Shown in Fig. 8, including processor 801, communication interface 802, memory 803 and communication bus 804, wherein processor 801, communication Interface 802, memory 803 complete mutual communication by communication bus 804,
Memory 803, for storing computer program;
Processor 801 when for executing the program stored on memory 803, realizes following steps:
The current operating environment information for the terminal device that application client in receiving terminal apparatus is sent;Current fortune Row environmental information be application client during startup, obtain and send after the current operating environment information of terminal device 's;
Judge in the calling code library prestored, if there is the calling of each API corresponding with current operating environment information Code;Call the calling code comprising each API for different running environment in code library;
If it exists, the calling code of each API corresponding with current operating environment information is sent to application client, So that application client receives the calling code of each API corresponding with current operating environment information, and in application program When operation will extremely call the predeterminated position of API, from the calling code of each API, target API corresponding with predeterminated position is determined Calling code;The calling code of performance objective API;Wherein, predeterminated position and AP I are corresponded.
Further, can also include above-mentioned API Calls method provided in an embodiment of the present invention in other process flows, It is no longer described in detail herein.
The communication bus that above-mentioned terminal device or server device are mentioned can be Peripheral Component Interconnect standard (Peripheral Component Interconnect, abbreviation PCI) bus or expanding the industrial standard structure (Extended Industry Standard Architecture, abbreviation EISA) bus etc..The communication bus can be divided into address bus, number According to bus, control bus etc..Only to be indicated with a thick line in figure, it is not intended that an only bus or one convenient for indicating The bus of seed type.
Communication interface is for the communication between above-mentioned terminal device or server device and other equipment.
Memory may include random access memory (Random Access Memory, abbreviation RAM), also may include Nonvolatile memory (Non-Volatile Memory, abbreviation NVM), for example, at least a magnetic disk storage.Further, Memory can also be that at least one is located remotely from the storage device of aforementioned processor.
Above-mentioned processor can be general processor, including central processing unit (Central Processing Unit, Abbreviation CPU), network processing unit (Network Processor, abbreviation NP) etc.;It can also be digital signal processor (Digital Signal Processor, abbreviation DSP), specific integrated circuit (Application Specific Integrated Circuit, abbreviation ASIC), field programmable gate array (Field-Programmable Gate Array, Abbreviation FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hardware components.
In another embodiment provided by the invention, a kind of computer readable storage medium is additionally provided, which can It reads to be stored with instruction in storage medium, when run on a computer, so that computer executes on any in above-described embodiment The API Calls method stated.
In another embodiment provided by the invention, a kind of computer program product comprising instruction is additionally provided, when it When running on computers, so that computer executes any above-mentioned API Calls method in above-described embodiment.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or any combination thereof real It is existing.When implemented in software, it can entirely or partly realize in the form of a computer program product.Computer program product Including one or more computer instructions.It is all or part of when loading on computers and executing above-mentioned computer program instructions Ground generates the process or function above-mentioned according to the embodiment of the present invention.Computer can be general purpose computer, special purpose computer, calculating Machine network or other programmable devices.Computer instruction may be stored in a computer readable storage medium, or from one Computer readable storage medium is transmitted to another computer readable storage medium, for example, computer instruction can be from a net Website, computer, server or data center by it is wired (such as coaxial cable, optical fiber, Digital Subscriber Line (English: Digital Subscriber Line, referred to as: DSL)) or wireless (such as infrared, wireless, microwave etc.) mode is to another net Website, computer, server or data center are transmitted.Above-mentioned computer readable storage medium can be computer can Any usable medium of access either includes the data storage such as one or more usable mediums integrated server, data center Equipment.Above-mentioned usable medium can be magnetic medium, and (for example, floppy disk, hard disk, tape), optical medium are (for example, digital video light Disk (English: Digital Video Disc, referred to as: DVD)) or semiconductor medium (such as solid state hard disk (English: Solid State Disk, referred to as: SSD)) etc..
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that There is also other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is all made of relevant mode and describes, same and similar portion between each embodiment Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for device, For terminal device, server device and storage medium embodiment, since it is substantially similar to the method embodiment, so description Fairly simple, the relevent part can refer to the partial explaination of embodiments of method.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention It is interior.

Claims (10)

1. a kind of application programming interface API Calls method, which is characterized in that applied to the application program visitor in terminal device Family end, comprising:
In the application client start-up course, the current operating environment information of the terminal device is obtained;
Obtain the calling code of each API corresponding with the current operating environment information;
When application program is run to the predeterminated position of API to be called, from the calling code of each API, determining and institute State the calling code of the corresponding target API of predeterminated position;Wherein, predeterminated position and API are corresponded;
Execute the calling code of the target API.
2. the method according to claim 1, wherein the acquisition is corresponding with the current operating environment information The step of calling code of each API, comprising:
The current operating environment information is sent to the server device connecting with the terminal equipment in communication, so that the service In the calling code library that end equipment judgement prestores, if there is the tune of each API corresponding with the current operating environment information Use code;Calling code comprising each API for different running environment in the calling code library;If it exists, then to institute State the calling code that application client returns to each API corresponding with the current operating environment information;
Receive the calling code for each API corresponding with the current operating environment information that the server device returns.
3. according to the method described in claim 2, it is characterized in that, the calling code of each API for same running environment In same calling code packet;It include running environment information in the code packet;
Described the step of sending the current operating environment information to the server device connecting with the terminal equipment in communication, packet It includes:
According to the running environment information for including in the code packet, judge to whether there is and the current operation ring in local cache The calling code of the corresponding each API of border information;
If it does not exist, then the current operating environment information is sent to the server device connecting with the terminal equipment in communication.
4. a kind of application programming interface API Calls method, which is characterized in that applied to the clothes being connect with terminal equipment in communication Business end equipment, comprising:
Receive the current operating environment information for the terminal device that the application client in the terminal device is sent;Institute State current operating environment information be the application client during startup, obtain the current operation of the terminal device It is sent after environmental information;
Judge in the calling code library prestored, if there is the calling of each API corresponding with the current operating environment information Code;Calling code comprising each API for different running environment in the calling code library;
If it exists, Xiang Suoshu application client sends the calling of each API corresponding with the current operating environment information Code, so that the application client receives the calling of each API corresponding with the current operating environment information Code, and when application program is run to the predeterminated position of API to be called, from the calling code of each API, determine with The calling code of the corresponding target API of the predeterminated position;Execute the calling code of the target API;Wherein, predeterminated position with API is corresponded.
5. a kind of application programming interface API Calls device, which is characterized in that applied to the application program visitor in terminal device Family end, comprising:
Running environment data obtaining module, for obtaining the terminal device in the application client start-up course Current operating environment information;
Code obtaining module is called, for obtaining the calling code of each API corresponding with the current operating environment information;
Code determining module is called, for when application program is run to the predeterminated position of API to be called, from each API Calling code in, determine the calling code of target API corresponding with the predeterminated position;Wherein, predeterminated position and API be one by one It is corresponding;
Code execution module is called, for executing the calling code of the target API.
6. a kind of application programming interface API Calls device, which is characterized in that applied to the clothes being connect with terminal equipment in communication Business end equipment, comprising:
Running environment information receiving module, for receiving the terminal of the transmission of the application client in the terminal device The current operating environment information of equipment;The current operating environment information be the application client during startup, Obtain the current operating environment information transmission later of the terminal device;
Judgment module, in the calling code library for judging to prestore, if exist corresponding with the current operating environment information The calling code of each API;Calling code comprising each API for different running environment in the calling code library;
Code sending module is called, if existing in the calling code library for prestoring corresponding with the current operating environment information The calling code of each API, Xiang Suoshu application client send each API corresponding with the current operating environment information Calling code so that the application client receives each API corresponding with the current operating environment information Calling code, and when application program is run to the predeterminated position of API to be called, from the calling code of each API, Determine the calling code of target API corresponding with the predeterminated position;Execute the calling code of the target API;Wherein, it presets Position and API are corresponded.
7. a kind of terminal device, which is characterized in that including processor, communication interface, memory and communication bus, wherein processing Device, communication interface, memory complete mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes any method and step of claim 1-3.
8. a kind of server device, which is characterized in that including processor, communication interface, memory and communication bus, wherein place Device, communication interface are managed, memory completes mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes method and step as claimed in claim 4.
9. a kind of computer readable storage medium, which is characterized in that be stored with computer in the computer readable storage medium Program realizes claim 1-3 any method and step when the computer program is executed by processor.
10. a kind of computer readable storage medium, which is characterized in that be stored with computer in the computer readable storage medium Program, the computer program realize method and step as claimed in claim 4 when being executed by processor.
CN201910487094.2A 2019-06-05 2019-06-05 Application programming interface calling method, device, equipment and medium Active CN110221880B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910487094.2A CN110221880B (en) 2019-06-05 2019-06-05 Application programming interface calling method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910487094.2A CN110221880B (en) 2019-06-05 2019-06-05 Application programming interface calling method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN110221880A true CN110221880A (en) 2019-09-10
CN110221880B CN110221880B (en) 2023-06-20

Family

ID=67819430

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910487094.2A Active CN110221880B (en) 2019-06-05 2019-06-05 Application programming interface calling method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN110221880B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112394953A (en) * 2020-11-16 2021-02-23 北京五八信息技术有限公司 Application program loading method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1495579A (en) * 2002-07-31 2004-05-12 ������������ʽ���� Image forming device, information processing device and edition correcting method
US20060195851A1 (en) * 2005-02-25 2006-08-31 Microsoft Corporation Multiple version interface
CN104142881A (en) * 2013-05-07 2014-11-12 腾讯科技(深圳)有限公司 Adaptive defect detecting method and device of application program programming interfaces
CN104598257A (en) * 2013-10-30 2015-05-06 华为技术有限公司 Method and device for remotely operating application program
CN105183484A (en) * 2015-09-28 2015-12-23 北京奇虎科技有限公司 Method and device for compatibility of multi-version application programming interface
US9760384B1 (en) * 2016-06-17 2017-09-12 International Business Machines Corporation Method to support multiple versions of APIs and to control run-time execution of an API

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1495579A (en) * 2002-07-31 2004-05-12 ������������ʽ���� Image forming device, information processing device and edition correcting method
US20060195851A1 (en) * 2005-02-25 2006-08-31 Microsoft Corporation Multiple version interface
CN104142881A (en) * 2013-05-07 2014-11-12 腾讯科技(深圳)有限公司 Adaptive defect detecting method and device of application program programming interfaces
CN104598257A (en) * 2013-10-30 2015-05-06 华为技术有限公司 Method and device for remotely operating application program
CN105183484A (en) * 2015-09-28 2015-12-23 北京奇虎科技有限公司 Method and device for compatibility of multi-version application programming interface
US9760384B1 (en) * 2016-06-17 2017-09-12 International Business Machines Corporation Method to support multiple versions of APIs and to control run-time execution of an API

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112394953A (en) * 2020-11-16 2021-02-23 北京五八信息技术有限公司 Application program loading method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110221880B (en) 2023-06-20

Similar Documents

Publication Publication Date Title
CN110187912B (en) Node selection method and device
US20040158829A1 (en) Downloading application software to a mobile terminal
US10430172B2 (en) Re-configuration in cloud computing environments
US7266370B2 (en) System and method for developing and deploying device independent applications
RU2339076C2 (en) Execution of non-verified programs in radio communication device
CN104699616A (en) Method, device and system for testing application
CN111782339B (en) Container creation method and device, electronic equipment and storage medium
CN108319662A (en) Page processing method, device, electronic equipment and readable storage medium storing program for executing
US11327724B2 (en) System and method that support application software development
CN111752582B (en) Software updating method and device in local area network and electronic equipment
CN104573497A (en) Processing method and device for starting items
CN110851204A (en) Application starting method and device and application packaging method and device
CN113064685A (en) H5 page loading method and device
CN114416396A (en) Interface version control method and device, electronic equipment and storage medium
CN111338829B (en) Calling method and device for remote procedure call service
CN110045998B (en) Method and device for loading dynamic library
CN110221880A (en) Application programming interface calling method, device, equipment and medium
CN112395034A (en) Page display method and device, electronic equipment and storage medium
CN110597513B (en) WEB interface generation method and related device
CN108287891A (en) A kind of application information method for pushing and server
CN104573495A (en) Startup item processing method and startup item processing device
CN109799997B (en) Management method for presetting third party application, intelligent terminal and storage medium
CN109756948B (en) Method and device for connecting wireless access point through application in user equipment
CN115080068A (en) Resource file transmission method, device, equipment and storage medium
CN110286936A (en) Hot restorative procedure, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant