CN104866383A - Interface calling method, apparatus, and terminal - Google Patents

Interface calling method, apparatus, and terminal Download PDF

Info

Publication number
CN104866383A
CN104866383A CN 201510289070 CN201510289070A CN104866383A CN 104866383 A CN104866383 A CN 104866383A CN 201510289070 CN201510289070 CN 201510289070 CN 201510289070 A CN201510289070 A CN 201510289070A CN 104866383 A CN104866383 A CN 104866383A
Authority
CN
Grant status
Application
Patent type
Prior art keywords
interface
parameter
call
request
target
Prior art date
Application number
CN 201510289070
Other languages
Chinese (zh)
Inventor
刘争辉
Original Assignee
北京金山安全软件有限公司
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

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING; 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication

Abstract

Embodiments of the invention disclose an interface calling method and terminal. The interface calling method comprises: receiving an interface calling request, wherein the interface calling request carries an interface identifier and an interface parameter corresponding to a target interface that a client script requires to call; determining a calling mode of the target interface according to the interface identifier; determining, according to the calling mode and the interface parameter, a first parameter in input parameters of a target interface function corresponding to the target interface; using the request identifier of the interface calling request and the first parameter as input parameters of the target interface function, and calling the target interface function; obtaining an output parameter returned after the target interface function is called, wherein the output parameter comprises the request identifier and a second parameter; and returning a calling result of the interface calling request corresponding to the request identifier to the client script based on the second parameter. The embodiments of invention may be used to improve development efficiency of an extension interface.

Description

-种接口调用方法、装置及终端 - kind of method calls the interface, and a terminal device

技术领域 FIELD

[0001] 本发明设及计算机技术领域,尤其设及一种接口调用方法、装置及终端。 Invention is provided [0001] The field of computer technology and, in particular, is provided, and one interface call method, and a terminal apparatus.

背景技术 Background technique

[0002] 随着互联网技术的发展,浏览器已成为移动终端上必备的应用软件之一,通过移动终端上的浏览器浏览网页时,浏览器内核对网页语法进行解释并擅染。 [0002] With the development of Internet technology, the browser has become an essential mobile terminal application software, browse the Web browser on the mobile terminal, web browser kernel to explain grammar and good at dyeing. 通常,浏览器内核提供一些标准接口供客户端脚本使用或调用,因此,通过在网页中加载客户端脚本,由浏览器解释执行该客户端脚本,可W实现网页的动态展示效果,增强网页的交互性。 Typically, the browser kernel provides a number of standard interfaces for client-side scripting or calls, therefore, by loading client-side script in a Web page, the browser interprets the implementation of the client-side scripting, you can W dynamic display of results pages, and enhance web pages interactivity. 例如:实现页面元素的特殊显示效果、响应用户动作、验证表单数据等等。 For example: to achieve special effects display page elements, in response to user actions, and so on form data validation.

[0003] 然而,浏览器内核本身提供的标准接口有限,因此,为满足Web网页的开发需求, 开发人员需根据需要开发出更多的扩展接口,W供Web网页的客户端脚本调用。 [0003] However, the standard interface browser kernel itself provides limited, therefore, in order to meet the development needs of Web pages, developers need to develop more expansion interfaces as needed, the client script calls for W Web pages. 目前,由于开发扩展接口的标准不统一,并没有一种统一来处理客户端脚本调用任意扩展接口的接口调用方法,因此,开发人员在开发扩展接口时,不仅需要针对该扩展接口所提供的功能设计一个接口函数,而且还需要针对该扩展接口设计出客户端脚本调用该接口的处理方法。 Currently, due to the development of extensions to the standard interface is not uniform, and not a unified client-side scripting to handle calls to any extension interface method call interface, so developers in the development of expansion interface, not only for the extension interface function provided an interface design function, but also need to interface design a treatment client script calls for the extension of the interface. 例如观有的接口开发方法如图la所示,开发接口A和接口B时,除开发出接口A的接口函数和接口B的接口函数外,还需针对接口A开发一套脚本调用接口A时的调用方法和针对接口B开发一套脚本调用接口B时的调用方法,导致开发效率低。 For example, some concept of the method shown in FIG La interface development, when development interface interfaces A and B, in addition to the interface function to develop port A and port B of the interface functions, the need to develop a port A when the script calls for interfaces A the call methods and method calls when the call interface B B to develop a script for the interface, resulting in low development efficiency.

发明内容 SUMMARY

[0004] 本发明实施例提供一种接口调用方法、装置及终端,可W提高扩展接口的开发效率。 [0004] An embodiment provides a method of interface calls, and a terminal apparatus, W can improve development efficiency expansion interface of the present invention.

[0005] 第一方面,本发明实施例提供一种接口调用方法,包括: [0005] In a first aspect, embodiments of the present invention provides a method call interface comprising:

[0006] 接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一; [0006] The call request reception interface, the interface call request carries the destination interface and the corresponding interface identifier client script interface parameters need to call one of the extended interface provided by the browser to the target interface;

[0007] 根据所述接口标识,确定所述目标接口的调用方式; [0007] In accordance with the interface identifier, is called to determine the target interface;

[000引根据所述调用方式和所述接口参数,确定所述接口标识对应的目标接口函数的输入参数中的第一参数; [000 called by the primers and according to the interface parameters, determining a first parameter of the input parameter corresponding target interface identifier of the interface functions;

[0009] 将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数; [0009] The interface call request and the request identifies a first target parameter as the input parameter of the interface function, the interface function call to the target;

[0010] 获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数; [0010] obtain an output parameter of the target interface returning to the calling function, the output parameter includes the request ID and the second parameter;

[0011] 基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0011] based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script.

[0012] 在第一方面的第一种可能的实现方式中,所述输出参数的数据类型为预设的第一数据类型; [0012] In a first possible implementation of the first aspect, the data type of the output parameter is a first predetermined data type;

[0013] 所述根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数之后,所述方法还包括: After [0013] The embodiment according to the invocation and the parameters of the interface, determining a first parameter of the input parameter corresponding target destination interface function in the interface, the method further comprising:

[0014] 将所述第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型; [0014] The first parameter format conversion, data type of the first parameter after conversion to the preset second data type;

[0015] 所述获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数之后,所述方法还包括: [0015] The output parameter obtaining the target interface returning to the calling function, the output parameter after the request comprising identification and the second parameter, the method further comprising:

[0016] 将所述第二参数进行格式转换,转换后的第二参数的数据类型为预设的第=数据类型。 [0016] The second parameter format conversion, data type of the second parameter after conversion to the preset type of data =.

[0017] 结合第一方面或第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数包括: [0017] with the first aspect or the first possible implementation of the first aspect, a second possible implementation of the first aspect of the embodiment according to the invocation and the interface parameters, determining the the first input parameter corresponding to the interface parameters of the target function in the target interface comprising:

[0018] 若所述调用方式为同步调用,将所述接口参数确定为所述目标接口函数的输入参数中的第一参数; [0018] If the call mode is a synchronous call, the interface parameters determined as the first parameter of the input parameter in the objective function interfaces;

[0019] 若所述调用方式为异步调用,将所述接口参数中除预设参数外的其它参数确定为所述目标接口函数的输入参数中的第一参数,所述预设参数用于标识回调函数。 [0019] If the call mode is an asynchronous call, to determine the interface parameters preset parameters other parameters except for the first parameter of the object parameter input interface functions in the preset parameters for identifying Callback.

[0020] 结合第一方面或第一方面的第一种可能的实现方式,在第一方面的第=种可能的实现方式中,所述基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本包括: [0020] with the first aspect or the first possible implementation of the first aspect, the first possible implementation = manner of the first aspect, based on the second parameter, corresponding to the request identifier Interface call returns the invocation request to the client script comprises:

[0021] 若所述调用方式为同步调用,将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本; [0021] If the call mode is a synchronous call, return the script to the client as a result of calling the second parameter of the call request corresponding to the request identifies an interface;

[0022] 若所述调用方式为异步调用,确定所述请求标识对应的目标回调函数,并将所述第二参数作为所述目标回调函数的输入参数,运行所述目标回调函数得到输出结果,进而将所述输出结果作为所述接口调用请求的调用结果返回给所述客户端脚本。 [0022] If the call mode is an asynchronous call, determining a corresponding target request identifies the callback function, and the second parameter as an input parameter of the object callback, the callback function operation to obtain the target output, Further outputs the result as the result of the call interface call request back to the client script.

[0023] 结合第一方面的第=种可能的实现方式,在第一方面的第四种可能的实现方式中,所述根据所述接口标识,确定所述目标接口的调用方式之后,所述方法还包括: After [0023] Combination = possible implementation of the first aspect, a fourth possible implementation manner of the first aspect, said interface according to the identifier, determining a target invocation interface, the the method further comprises:

[0024] 若所述调用方式为异步调用,将回调信息保存至回调数据库中,所述回调信息包括所述请求标识和所述预设参数所标识的回调函数; Save [0024] If the call mode is an asynchronous call to the callback information database callback, the callback request includes said identifying information and said preset parameters identified by a callback function;

[0025] 所述确定所述请求标识对应的目标回调函数,包括: [0025] determining the request identifies the corresponding target callback function, comprising:

[0026] 若所述调用方式为异步调用,根据所述请求标识从所述回调数据库中查询所述请求标识对应的回调信息; [0026] If the call mode is an asynchronous call, the callback request corresponding to the identification information according to the request identifies callback query from the database;

[0027] 将所述回调信息指定的回调函数确定为目标回调函数。 [0027] Specifies the callback function callback information is determined as the target callback function.

[002引结合第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,所述将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本之后,所述方法还包括: [002 primer binding fourth possible implementation of the first aspect, the fifth possible implementation manner of the first aspect, the second parameter as the call request for calling an interface corresponding to the request identifier the results returned to the client after the script, the method further comprising:

[0029] 删除所述回调数据库中所述请求标识对应的回调信息。 [0029] Remove the callback request a callback information of the database corresponding to the identifier.

[0030] 结合第一方面或第一方面的第一种可能的实现方式,在第一方面的第六种可能的实现方式中,所述根据所述接口标识,确定所述目标接口的调用方式包括: [0030] with the first aspect or the first possible implementation of the first aspect, a sixth possible implementation manner of the first aspect, said interface identifier according to the determined interface is called by the target include:

[0031] 根据所述接口标识,从预设的接口数据库中查询所述接口标识对应的接口信息, 所述接口信息包括接口标识和调用方式; [0031] The said interface identifier, interface identifier of the interface information corresponding to the query from the default database interfaces, the interface information includes an interface identifier and a call mode;

[0032] 将所述接口数据库中该接口标识对应的调用方式确定为所述目标接口的调用方式。 [0032] The determination of the target invocation interface in the interface to the database to identify the corresponding interface is called.

[0033] 第二方面,本发明实施例提供一种接口调用装置,包括: [0033] a second aspect, the present invention provides a device interface calls, comprising:

[0034] 接收模块,用于接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之* [0034] a receiving module, configured to receive a request for calling the interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target interface extended interface provided by the browser *

[0035] 方式确定模块,用于根据所述接口标识,确定所述目标接口的调用方式; [0035] The mode determination module, according to the interface identification, to determine the target invocation interface;

[0036] 参数确定模块,用于根据所述调用方式和所述接口参数,确定所述接口标识对应的目标接口函数的输入参数中的第一参数; [0036] The parameter determination module, according to the call mode and the interface parameters, determining a first parameter of the input parameter corresponding target interface identifier of the interface functions;

[0037] 调用模块,用于将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数; [0037] The invoking module, the interface call request for requesting the identifier and the parameter as an input parameter of the first target interface function, the interface function call to the target;

[003引获取模块,用于获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数; [Cited obtaining module 003, configured to obtain the output parameters of the target interface returning to the calling function, the output parameter includes the request ID and the second parameter;

[0039] 返回模块,用于基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0039] returning module, based on the second parameter, the call request corresponding to the identification result of the call to the interface request is returned to the client script.

[0040] 在第二方面的第一种可能的实现方式中,所述输出参数的数据类型为预设的第一数据类型,所述装置还包括: [0040] In a first possible implementation of the second aspect, the data type of the parameter to output data of a first predetermined type, said apparatus further comprising:

[0041] 第一转换模块,用于将所述第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型; [0041] The first conversion module, a first parameter for a format conversion, data type of the first parameter after conversion to the preset second data type;

[0042] 第二转换模块,用于将所述第二参数进行格式转换,转换后的第二参数的数据类型为预设的第=数据类型。 [0042] The second conversion module, the second parameter for the format conversion, data type of the second parameter after conversion to the preset type of data =.

[0043] 结合第二方面或第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述参数确定模块具体用于: [0043] combination with the second aspect or the first possible implementation of the second aspect, the second aspect of the second possible implementation manner, the parameter determination module is configured to:

[0044] 若所述调用方式为同步调用,将所述接口参数确定为所述目标接口函数的输入参数中的第一参数; [0044] If the call mode is a synchronous call, the interface parameters determined as the first parameter of the input parameter in the objective function interfaces;

[0045] 若所述调用方式为异步调用,将所述接口参数中除预设参数外的其它参数确定为所述目标接口函数的输入参数中的第一参数,所述预设参数用于标识回调函数。 [0045] If the call mode is an asynchronous call, to determine the interface parameters preset parameters other parameters except for the first parameter of the object parameter input interface functions in the preset parameters for identifying Callback.

[0046] 结合第二方面或第二方面的第一种可能的实现方式,在第二方面的第=种可能的实现方式中,所述返回模块包括: [0046] combination with the second aspect or the first possible implementation of the second aspect, = first possible implementation of the second aspect of the return module comprising:

[0047] 同步返回单元,若所述调用方式为同步调用,将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本; [0047] synchronization return unit, if the call invocation is synchronous, the second parameter as a result of the call request to invoke the requested interface corresponding to the identifier is returned to the client script;

[0048] 异步返回单元,若所述调用方式为异步调用,确定所述请求标识对应的目标回调函数,并将所述第二参数作为所述目标回调函数的输入参数,运行所述目标回调函数得到输出结果,进而将所述输出结果作为所述接口调用请求的调用结果返回给所述客户端脚本。 [0048] asynchronous return unit, if the calling mode is an asynchronous call, determining a corresponding target request identifies the callback function, and the second parameter as an input parameter of the callback function of the target, the target operating callback to obtain an output result, and further outputs the result as the result of the call interface call request back to the client script.

[0049] 结合第二方面的第=种可能的实现方式,在第二方面的第四种可能的实现方式中,所述装置还包括: [0049] Combination = possible implementation of the second aspect, in a fourth aspect of the second possible implementation, the apparatus further comprising:

[0化0] 保存模块,用于若所述调用方式为异步调用,将回调信息保存至回调数据库中,所述回调信息包括所述请求标识和所述预设参数所标识的回调函数; [0 of 0] storage module, configured to, if the calling mode is an asynchronous call, the callback to the callback information stored in the database, the correction information request comprises the identifier and the preset parameters identified by a callback function;

[0化1] 所述同步返回单元具体用于: [0 of 1] returns the synchronization unit is configured to:

[0052] 若所述调用方式为异步调用,根据所述请求标识从所述回调数据库中查询所述请求标识对应的回调信息; [0052] If the call mode is an asynchronous call, the callback request corresponding to the identification information according to the request identifies callback query from the database;

[0053] 将所述回调信息指定的回调函数确定为目标回调函数。 [0053] The correction information specifying the callback function determined as the target callback function.

[0054] 结合第二方面的第四种可能的实现方式,在第二方面的第五种可能的实现方式中,所述装置还包括: [0054] combination with the fourth aspect of the second possible implementation manner, a fifth possible implementation of the second aspect, said apparatus further comprising:

[0055] 删除模块,用于删除所述回调数据库中所述请求标识对应的回调信息。 [0055] The deleting module for deleting the database corresponding to the information identifying a callback request to the callback.

[0化6] 结合第二方面或第二方面的第五种可能的实现方式,在第二方面的第六种可能的实现方式中,所述方式确定模块具体用于: [0 of 6] combination with the second aspect or fifth possible implementation of the second aspect, a sixth possible implementation manner of the second aspect, the mode determining module is configured to:

[0化7] 根据所述接口标识,从预设的接口数据库中查询所述接口标识对应的接口信息, 所述接口信息包括接口标识和调用方式; [0 of 7] based on the interface identifier, interface identifier of the interface information corresponding to the query from the default database interfaces, the interface information includes an interface identifier and a call mode;

[0化引将所述接口数据库中该接口标识对应的调用方式确定为所述目标接口的调用方式。 [0 of primers to the target is determined as the interface is called the interface of the database is called by the interface corresponding to the identifier.

[0化9] 第=方面,本发明实施例提供一种终端,其特征在于,包括如上所述的接口调用装置。 [Formula 9 0] = a first aspect, embodiments of the present invention provides a terminal, wherein the call comprises a device interface as described above.

[0060] 本发明实施例中,接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定所述目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述接口标识对应的目标接口函数的输入参数中的第一参数;将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0060] The embodiments of the present invention, the reception interface invocation request, the interface call request carries the destination interface and the corresponding interface identifier with a client-side script interface parameters need to call the target interface in the extended interface provided by the browser a; the interface according to the identifier, determining the target invocation interface; interface parameters according to the embodiment and the call, determining a first parameter of the input parameter corresponding target interface identifier of the interface function; the Interface call request identifies the request and the first parameter as the target interface function of the input parameters, the interface function call to the target; output parameter obtaining the target interface returning to the calling function, the request comprises said output parameter and a second identification parameter; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用,浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数,可W提高扩展接口的开发效率。 Whereby, when the expansion interface developers, the ability to develop the corresponding interface function expansion interface, the interface can be extended to improve W development efficiency.

附图说明 BRIEF DESCRIPTION

[0061] 为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可W根据该些附图获得其他的附图。 [0061] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, briefly describes the accompanying drawings required for describing the embodiments used in the following embodiments will be apparent in the following description of the drawings Some embodiments of the present invention are embodiment, those of ordinary skill in the art is concerned, without any creative effort, W may also obtain other drawings according to the plurality of reference.

[0062] 图la是现有方法提供的一种接口调用的示意图; [0062] FIG. La is a schematic diagram of a conventional method of interface calls provided;

[0063] 图1是本发明实施例提供的一种接口调用方法的流程示意图; [0063] FIG. 1 is a schematic flow of a method for calling an interface according to an embodiment of the present invention;

[0064] 图化是图1提供的一种接口调用的示意图; [0064] FIG is a schematic diagram of FIG. 1, an interface provided in the call;

[00化]图2是本发明实施例提供的一种接口调用方法的另一流程示意图; [Of 00] FIG. 2 is another process invokes a method of an interface according to an embodiment of the present invention, a schematic view;

[0066] 图3是本发明实施例提供的一种接口调用装置的结构示意图; [0066] FIG. 3 is a schematic diagram of the structure of a device interface calls to an embodiment of the present invention;

[0067] 图4是本发明实施例提供的一种接口调用装置的另一结构示意图; [0067] FIG. 4 is another diagram illustrating a configuration interface call apparatus according to an embodiment of the present invention;

[0068] 图4a是图4提供的其中一种返回模块的结构示意图; [0068] Figure 4a is one of the return module of Figure 4 provides a schematic view of the structure;

[0069] 图5是本发明实施例提供的一种接口调用装置的又一结构示意图; [0069] FIG. 5 is a diagram showing still another structure of an interface call device according to an embodiment of the present invention;

[0070] 图6是本发明实施例提供的一种终端的结构示意图; [0070] FIG. 6 is a structural diagram of a terminal according to an embodiment of the present invention;

[0071] 图7是本发明实施例提供的一种接口调用装置的再一结构示意图。 [0071] FIG. 7 is a schematic view of another structure of a device interface calls according to an embodiment of the present invention.

具体实施方式 detailed description

[0072] 下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本发明的一部分实施例,而不是全部的实施例。 [0072] below in conjunction with the present invention in the accompanying drawings, technical solutions in the embodiments will be apparent to the present invention, completely described, obviously, the described embodiments are merely a part of the present embodiment of the invention, rather than all of Example. 基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。 Based on the embodiments of the present invention, all other embodiments of ordinary skill in the art without any creative effort shall fall within the scope of the present invention.

[0073] 本发明实施例提供了一种接口调用方法、装置及终端,下面将结合附图1-附图7 对本发明实施例提供的一种接口调用方法、装置及终端分别进行详细介绍。 [0073] Example embodiments provide a method of calling the interface of the present invention, a terminal apparatus and, in conjunction with the following embodiment 7 of the drawings The invention will 1- calling method, and a terminal apparatus are provided, an interface is described in detail.

[0074] 请参见图1,图1是本发明实施例提供的一种接口调用方法的流程示意图,在本发明实施例中,该方法可W包括W下步骤。 [0074] Referring to FIG. 1, FIG. 1 is a schematic flow chart of a method for calling the interface according to an embodiment of the present invention, in the embodiment of the present invention, the method may comprise W W next step.

[0075] S101 ;接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一。 [0075] S101; receive interface invocation request, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the interface is one of the target expansion interface provided by the browser.

[0076] 在本发明实施例中所描述的方法可W用于终端上的浏览器或类似于浏览器的产品中,所述终端可W是计算机、IPAD、手机等终端,也可W是其它智能设备,具体的,本发明实施例不作任何限制。 [0076] In the product of the process described in the embodiments of the present invention may be used in W terminal on the browser or browser-like, the W terminal may be a computer, IPAD, mobile phones and other terminals may also be other W smart devices, particularly, embodiments of the invention without any limitation.

[0077] 通常,为丰富网页的动态展示效果,增强网页与用户的交互性,浏览器向网页提供了大量接口,供网页中加载的客户端脚本调用,浏览器解释、执行该客户端脚本。 [0077] In general, for the rich web of dynamic display of results, enhanced interactive website with the user, the browser provides a number of interfaces to the website for the page to load client script calls the browser interprets and executes the client script. 例如:浏览器接收到客户端脚本的接口调用请求时,根据该接口调用请求携带的信息运行该信息所指定的目标接口对应的接口函数,从而实现相应的功能。 For example: When the browser receives the scripting interface client invocation request, the operation information corresponding to the designated target interface interface function based on the information carried in the request interface calls, thereby realizing the corresponding function. 因此,浏览器在加载网页的过程中, 若网页中的客户端脚本需要调用浏览器提供的扩展接口,则接收接口调用请求。 Therefore, in the course of the browser loads the page, if the client-side scripting web pages need to call expansion interface provided by the browser, the receiving interface call request.

[007引S102 ;根据所述接口标识,确定所述目标接口的调用方式。 [007 cited S102; accordance with the interface identifier, is called to determine the target interface.

[0079] 接口的调用方式包括问步调用和异步调用,其中,问步调用是一种阻塞式调用,调用方要等待被调用方执行完毕后才返回,属于单向调用;异步调用是一种双向调用,类似于消息或事件的处理机制,调用方仅发生操作请求,不等被调用方执行完毕而立即返回,被调用方在执行完毕后主动调用调用方提供的回调函数(caUback),将执行结果返回给调用方,因此,异步调用可W提升浏览器执行网页的效率。 [0079] Q comprises an interface called by step with and asynchronous calls, wherein Q is a blocking step with call waiting caller to the callee returns after execution is completed, the one-way call belongs; is an asynchronous invocation two-way call, message or event handling mechanism similar to the operation requesting the caller only occur, ranging from the callee finished immediately returned, the callee automatically call the callback function (caUback) supplied by the caller after the execution is completed, the the results returned to the caller, therefore, W asynchronous call can improve the efficiency of execution of the web browser. 通常,开发人员开发出扩展接口的接口函数后,会根据扩展接口所实现的功能预先设置该接口的调用方式。 Typically, after an expansion interface developers to interface function, based on the function expansion interface implemented is set in advance is called by the interface. 例如,假设客户端脚本调用接口A时,无需接口A的返回结果即可执行后续操作,则为提高网页的运行效率,可W将接口A的调用方式设置为异步调用,从而,接口A的接口参数中存在一个表示回调函数的参数,该参数与接口需要实现的具体功能无关,用于返回接口的运行结果。 For example, suppose client A script calls the interface, without the need to return the results of the port A performs a subsequent operation, for the page to improve the efficiency, can be called by the interface W A is set to an asynchronous call to the interface port A represents a parameter independent of the presence of callback parameter, the specific features and parameters need to implement the interface, the interface for returning the results. 再例如,假设客户端脚本调用接口B时,接口B的返回结果为后续操作的前提,则可W将接口B的调用方式设置为同步调用。 When another example, assume that the client script call interface B, port B returns the result as a precondition for subsequent operations, will be called by the interface W B is set to synchronous calls.

[0080] 作为一种示例,可W是预设的接口数据库中记录有扩展接口的接口信息,所述接口信息包括接口标识和调用方式,所述接口标识可W是接口函数的接口名称,也可W是与接口名称一一对应的其它标识符,具体的,本发明实施例不作限制;调用方式包括同步调用和异步调用。 [0080] As an example, the interface may be W is the default database interface information is recorded in the expansion interface, the interface information includes an interface identifier and invocation, the interface identification may be the name of the interface is W interface functions, but also W is other identifier may be the name of one correspondence with the interface, a specific embodiment of the present invention is not limited; Called includes a synchronous call and an asynchronous call. 为方便说明,假设接口标识为接口名称,所提供的扩展接口有3个,则接口数据库的存储形式可W如表1所示,表1是本发明实施例提供一种接口数据库的存储示意。 For the convenience of illustration, assume that the name of the interface identifier of the interface, there are provided three expansion interface, the interface to the database may be stored in the form of W are as shown in Table 1, Table 1 is a schematic embodiment of an interface that provides storage database according to the present invention.

[0081] 表1 [0081] TABLE 1

[0082] [0082]

[0083] 从表1可知,在浏览器所提供的扩展接口中,接口标识分别为"recor地isto巧"和"downloa加rl"的接口所对应的调用方式为异步调用,接口标识为"playAudio"的接口所对应的调用方式为同步调用。 [0083] From Table seen 1, the extended interface provided by the browser, the interface identifier are "Recor to isto clever" and "Downloa plus rl is an" interface corresponding to the invocation of an asynchronous call, the interface identified as "playAudio "interface corresponding to the call for the synchronous call. 因此,本发明实施例中,可W根据接口调用请求中所携带的接口标识,从接口数据库中查询出所述接口标识对应的目标接口的调用方式。 Accordingly, an embodiment of the present invention, W in accordance with the interface identifier carried in the call request interface, the query from the interface to the database is called by the target interface corresponding to the interface identifier.

[0084] 作为另一种示例,也可W是接口调用请求所携带的接口参数中包含有标识目标接口的调用方式的参数。 Interface parameters [0084] As another example, the interface may be W is carried in the call request contains parameters identifying a target invocation interface. 例如:可W假设接口参数中的第一个参数用来表示目标接口的调用方式,用"1"表示同步调用,用"0"表示异步调用,当然,表示目标接口的调用方式的参数也可W是接口参数中位于其它位置处的参数,表示调用方式的具体数值也可W是其它字符, 本发明实施例不作限制。 For example: Suppose the interface parameter W may be the first parameter is used to indicate the target invocation interface, with "1" indicates synchronous call, with "0" indicating an asynchronous call, of course, a parameter indicating a target invocation interface may be W is located at the other interface parameters position parameters, a specific value may also be called by other characters W, embodiments of the present invention is not limited. 但基于该假设,可W根据接口参数中第一个参数的具体数值确定目标接口的调用方式,若获取到该参数为"1",则可W确定接口标识对应的目标接口的调用方式为同步调用;若为"0",则可W确定接口标识对应的目标接口的调用方式为异步调用。 But this assumption, W may be determined according to the target interface is called by the interface parameters specific values ​​of the first parameter, if this parameter is acquired is "1", W may be determined corresponding to the target interface identifier is called synchronous interface call; if it is "0", W may be determined interface is called by the target interface identifier corresponds to asynchronous calls. 值得说明的是,本发明实施例对标定目标接口的调用方式的参数的具体形式不作限制,预先约定好标定规则即可。 It should be noted that the specific embodiments of the invention in the form of calibration parameters is called by the target interface is not limited, to pre-agreed rules good calibration. 本发明实施例中,可W根据接口调用请求中所携带的接口参数,确定所述接口标识对应的目标接口的调用方式。 Embodiments of the present invention, may be in accordance with the interface parameter called W carried in the request interface, determining a target invocation interface corresponding to the interface identifier. 为方便后续步骤的说明,本发明实施例W第一种示例为例。 For ease of subsequent steps, a first embodiment W exemplary embodiment of the present invention as an example.

[00财S103 ;根据所述调用方式和所述接口参数,确定所述接口标识对应的目标接口函数的输入参数中的第一参数。 [00 fiscal S103; the first parameter of the input parameter and is called by the interface parameters, determining the corresponding target interface identifier in accordance with the interface function.

[0086] 由于浏览器在分别处理异步调用和同步调用的接口调用请求时存在差异,异步调用需调用方提供一个标识回调函数的参数,被调用方在执行完毕后通过该回调函数返回目标接口函数的执行结果;同步调用是被调用方在执行完毕后直接返回目标接口函数的执行结果。 [0086] Because of the browser there is a difference in the call request interface were treated asynchronous invocation from a synchronous and asynchronous call required the caller to provide a parameter identifying the callback, the called party returns the target interface functions through the callback function after the implementation of execution result; synchronous call is returned directly target interface function caller after the implementation of the execution result. 因此,若调用方式为异步调用,则接口调用请求所携带的接口参数中存在一个标识回调函数(caUback)的预设参数,该预设参数由调用方提供,被调用方负责调用该预设参数标识的回调函数。 Thus, if the parameters of the interface is called by asynchronous call, the interface call request identifier carried in the presence of a callback function (caUback) preset parameters, the predetermined parameters provided by the caller, the called party is responsible for calling the preset parameter callback identity.

[0087] 本发明实施例中,规范化客户端脚本调用接口的方式,例如,表示同步调用和异步调用的脚本可W如代码1所示。 Embodiment [0087] In the present invention, standardized call interface client script manner, e.g., a script indicates synchronous and asynchronous calls may be calls W 1 as shown in the code.

[008引代码1 [008 Primer Code 1

[0089] //同步调用,操作结果通过返回值获得 [0089] // synchronous call returns the operation result value is obtained by

[0090] functionsyncinterface(argl,arg2,......); [0090] functionsyncinterface (argl, arg2, ......);

[00川//异步调用,操作结果通过回调函数caUback获得 [00 Sichuan // asynchronous calls, operating results obtained by the callback function caUback

[0092] functionasyncinterface(argl,arg2,......,callback); [0092] functionasyncinterface (argl, arg2, ......, callback);

[0093] //回调函数规范 [0093] // callback function specification

[0094] functionasyncCal化ack(Object); [0094] functionasyncCal of ack (Object);

[0095] 从代码1可W看出,本发明实施例规范化了脚本调用接口的规范,其中,接口参数(argl、arg2等)的个数和数据类型根据实际需求设定。 [0095] W can be seen from the code 1, Example standardized script call interface specification of the present invention, wherein the interface parameters (argl, arg2, etc.) the number and type of data set according to actual demand. 在异步调用中,可W将接口参数中的最后一个参数用来表示回调函数的参数,当然,也可W是接口参数中位于其它位置处的参数,具体的,本发明实施例不作限制,预先达成约定即可。 In asynchronous call may be W last argument interface parameters for a parameter indicative of the callback function, of course, it may be W is the interface parameters located at other locations of the parameters, Specifically, embodiments of the present invention is not limited in advance agreement can be reached. 异步调用中的回调函数用于将调用结果通知给客户端脚本,其中,回调函数的规范也在代码1中列出,它接受一个输入参数,输入参数的类型可W是脚本支持的通用数据类型,例如成bject对象。 Asynchronous callback function call for calling the script result to the client, wherein the callback function specifications are listed in a code, which accepts an input parameter, the type of input parameter W is a common data types can be supported scripting such as bject objects.

[0096] 本发明实施例中,若调用方式为同步调用,则根据接口调用请求携带的接口参数, 可W直接确定该接口参数为目标接口对应的目标接口函数的输入参数中的第一参数。 [0096] Example embodiments of the present invention, if a call for the synchronous call, the request interface parameters carried in the call to the interface, this interface can be directly determined parameter W for the first input parameter corresponding to the interface parameters of the target function in the target interface. 若调用方式为异步调用,则根据接口调用请求携带的接口参数,确定该接口参数中除预设参数外的其它参数为目标接口对应的目标接口函数的输入参数中的第一参数,其中,预设参数用于标识回调函数,每个预设参数对应一个回调函数。 If the call mode is an asynchronous call, the parameters carried in the request interface interface calls, determine the interface parameters preset parameters other parameters except for the parameter of the first input parameter corresponding to the target interface in the objective function of the interface, wherein the pre- parameter identifies the callback function is provided, each corresponding to a preset parameter callback function.

[0097] S104 ;将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数。 [0097] S104; requested the interface call request identifies the first parameter and the interface function as the target of the input parameters, the target interface function call.

[009引具体实现中,在将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数之前,可W确定所述接口调用请求的请求标识。 Before [009 primers specific implementation, the request identifies the first parameter and the interface call request interface function as the target of the input parameters, the interface function call to the target, W may determine that the interface call request request ID. 进一步的,考虑到浏览器在加载网页的过程中,会存在同时处理多项接口调用请求的情况, 因此,采用请求标识来标定客户端脚本调用接口的每项接口调用请求,该请求标识与其对应的接口调用请求的所有信息关联,所述信息包括该接口调用请求的接口标识、接口参数、 调用结果等,从而,通过请求标识来跟踪每项接口调用请求及调用结果。 Further, taking into account the browser while loading the page, there will be simultaneous handling of multiple interface call request, therefore, the use of each interface call request identifies the request to calibrate the client script call interface, the request identifies the corresponding All interfaces associated with call information request, the information includes an interface identifier of the interface call request, the interface parameters, like the call, so that, by tracking each request identifies the request and calls the interface call results. 本发明实施例中, 接收到接口调用请求后,确定该接口调用请求的请求标识,其中,请求标识可W是浏览器内核接收到接口调用请求时自动分配的。 After embodiments of the present invention, the interface invocation request is received, it is determined that the interface call request identifies the request, wherein the request identifies a kernel may be W is received by the browser automatically assigned when the interface invocation request. 可知,一个请求标识唯一标定一项接口调用请求,且请求标识与该项接口调用请求所携带的接口标识和接口参数关联。 Shows that a request identifies a unique calibration interface call request, and the request interface identification and interface parameters associated with the identification request interface calls carried.

[0099] 本发明实施例中,将接口函数的设计方式进行规范化,即每个接口函数接收一个请求标识作为输入参数的其中一个参数,且将该请求标识也作为输出参数的其中一个参数。 [0099] embodiment of the present invention, the design of the interface function is normalized manner, i.e., each interface receives a request for identifying a function as an input parameter, wherein a parameter, and the request identifies also as an output parameter of one of the parameters. 例如:将请求标识作为接口函数的输入参数的其中一个参数,即输入参数包括请求标识和第一参数;将该请求标识作为接口函数的输出参数的其中一个参数,即输出参数包括请求标识和第二参数,请求标识和第二参数关联。 For example: The request identifies one of the parameters as input parameters of the interface functions, i.e., input parameters include a first parameter and a request identifier; wherein the request identifies a parameter as an output parameter of the interface functions, i.e., the output parameter includes a request identifier and two parameters, and the second request identifies the associated parameter. 从而,接口函数执行完毕后,获取该接口函数的输出参数,输出参数包括请求标识和第二参数,通过请求标识区分该请求标识关联的第二参数为哪项接口调用请求的调用结果。 Thus, the interface function is finished, obtain an output parameter of the interface function, comprising a request identifier output parameter and the second parameter, the second parameter of the request by the request identifier distinguishing identifier associated with a call interface call request Which results.

[0100] 具体实现中,将请求标识和第一参数作为目标接口对应的目标接口函数的输入参数,调用该目标接口函数,即运行该目标接口函数。 [0100] In a specific implementation, the request identifies a first parameter as input parameters and a target destination interface corresponding to the interface function, the interface function call to the target, i.e., the operation target interface function.

[0101] S105;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数。 [0101] S105; output parameter obtaining the target interface returning to the calling function, the output parameter comprises the request identification and the second parameter.

[0102] 本发明实施例中,接口函数的输出参数包括请求标识和第二参数,其中,第二参数为该接口函数实现接口功能后用来返回给客户端脚本的参数,请求标识用来标识该第二参数为客户端脚本的哪项接口调用请求的调用结果。 [0102] Example embodiments of the present invention, the output parameters of the interface function comprises a request identifier and a second parameter, wherein the second parameter for the interface functions to implement an interface function returns to the client-side script parameters, an identifier for identifying the request the second parameter is the result of the call client-side script which interface call request.

[0103] 具体实现中,目标接口函数运行完毕后,获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数。 [0103] In specific implementation, the objective function is the interface operation is completed, the output parameter obtaining the target interface returning to the calling function, the output parameter comprises the request identification and the second parameter.

[0104] S106;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0104] S106; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script.

[0105] 作为一种示例,若调用方式为同步调用,由于调用方需等待被调用方返回调用结果后才执行后续操作,因此,将第二参数作为请求标识对应的接口调用请求的调用结果直接返回给调用方,其中,请求标识与该第二参数关联。 [0105] As an example, if a call for the synchronous call, the caller subsequent operations due to the need to wait for a result to be returned to the calling party after the call, therefore, the second parameter as the result of a direct call request for calling an interface corresponding request identifier returned to the caller, wherein the request identifies the second parameter is associated with.

[0106] 作为另一种示例,若调用方式为异步调用,由于调用方无需等待被调用方返回调用结果后即可继续执行后续操作,调用结果通过回调函数返回给调用方。 [0106] As another example, if a call mode is an asynchronous call, to continue the subsequent operations without waiting for the caller because the called party returns the call a result, call returns to the caller via the callback function. 因此,被调用方将第二参数作为回调函数的输入参数,通过调用该回调函数的方式返回请求标识对应的接口调用请求的调用结果给调用方,其中,请求标识与该第二参数关联,回调函数为请求标识对应的接口调用请求所携带的接口参数中标定的预设参数。 Thus, the callee second parameter as an input parameter of the callback function, through the callback function returns the invocation request to invoke a request corresponding to the identification result of the call to the caller interface, wherein the request identifies the parameters associated with the second callback interface parameters for the function corresponding to the interface call request identifier carried in the request for a preset calibration parameters. 可W理解的,调用方为客户端脚本,被调用方为浏览器。 W can understand the caller to client-side scripting, the callee for the browser. 从而,将接口调用请求的调用结果返回给客户端脚本,完成接口的调用。 Thus, the interface call requesting invocation result is returned to the client-side script, complete call interface.

[0107] 为方便说明,可W将本发明方法理解为接口中间层,如图化所示,图化是图1提供的一种接口调用的示意图。 [0107] For convenience of explanation, the method of the present invention can be understood that W is an interface of the intermediate layer, as shown in of FIG is a schematic diagram of FIG. 1, an interface calls provided. 浏览器在执行网页的过程中,若网页中的客户端脚本需要调用浏览器提供的扩展接口,则接口中间层接收接口调用请求,该接口调用请求中携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,其中,目标接口为浏览器所提供的扩展接口中的任一扩展接口;采用上述方法调用目标接口对应的目标接口函数,并将该目标接口函数的运行结果作为该接口调用请求的的调用结果返回给客户端脚本。 Browser during the execution of the page, if the client-side script page needs to call expansion interface provided by the browser, the interface of the intermediate layer receives the call request interface, the call request interface carries the client-side script needs to call the destination interface corresponding to interface identification and interface parameters, wherein the target interface is any expansion interface provided by the browser in an expansion interface; the above-described method calls the target interface function corresponding to the target interface, and operation results of the target as a function of the interface of the interface call request to call the results back to the client script. 从而, 通过该接口中间层统一处理接口的调用流程,开发人员在开发扩展接口时,只需针对扩展接口开发出对应的接口函数即可,无需针对每个扩展接口都设计一套该接口的调用方法, 降低工作量,提高开发效率。 Whereby, via the interface unitary intermediate layer interface call flow, the developer in the development of expansion interface, developed only for expansion interface corresponding to the interface function, without expansion interface is designed for each set of invoking the interface methods to reduce workload and improve development efficiency.

[0108] 在本发明实施例描述的接口调用方法中,接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数; 将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0108] In the interface method invocation described in the present embodiment of the invention, the invocation request reception interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target interface to the browser one extension provided by the interface; the interface according to the identifier, determining a target invocation interface; a first parameter of the input parameters of the target and is called by the interface parameters, determining the target function corresponding to the interface in accordance with the interface ; request the interface call request identifies the first parameter and the interface function as the target of the input parameters, the interface function call to the target; output parameter obtaining the target interface returning to the calling function, said output parameter the request includes identification and the second parameter; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用, 浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数,提高开发效率。 Whereby, when the expansion interface developers, the ability to develop the expansion interface corresponding to the interface function, to improve development efficiency.

[0109] 请参见图2,图2是本发明实施例提供的一种接口调用方法的另一流程示意图,在本发明实施例中,该方法可W包括W下步骤。 [0109] Referring to FIG. 2, FIG. 2 is another schematic flow chart of a method call to an interface according to an embodiment of the present invention, in the embodiment of the present invention, the method may comprise W W next step.

[0110] S201 ;接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数。 [0110] S201; receive interface invocation request, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script.

[0111] S202 ;根据所述接口标识,确定所述目标接口的调用方式。 [0111] S202; accordance with the interface identifier, determining a target invocation interface.

[0112] 具体实现中,根据接口调用请求所要调用的目标接口,确定该目标接口的调用方式,所述调用方式包括同步调用和异步调用。 [0112] In specific implementation, the interface according to the target interface invocation request to be called, to determine the target interface is called, the call invocation includes a synchronous and asynchronous calls. 通常,各接口的接口信息预先存储在接口数据库中,所述接口信息包括接口标识和调用方式。 Typically, each of the interface to the interface information stored in advance in a database, the interface information includes an interface identifier and invocation. 当浏览器接收到该接口调用请求时,根据该接口调用请求中携带的接口标识,从接口数据库中查询该接口标识对应的接口信息,接口信息包括接口标识和调用方式;从而,将接口数据库中该接口标识对应的调用方式确定为目标接口的调用方式。 When the browser receives the interface call request according to the interface call request interface identifier carried in the interface information of the interface identifier corresponding to a query from the database interface, the interface information includes an interface identifier and invocation; thus, interface database this is called the interface corresponding to the identifier is determined as the target invocation interface. 当然,目标接口的调用方式也可W是客户端脚本调用该目标接口时, 在接口调用请求的接口参数中标定,具体的,本发明实施例不作限制。 Of course, the interface is called the target W may also be a client-side script calls the target interface, the interface call interface parameters in the calibration request, a specific embodiment of the present invention is not limited.

[0113] 但作为一种优选的实施方式,确定目标接口的调用方式可W是根据接口标识,从预设的接口数据库中查询该接口标识对应的接口信息,所述接口信息包括接口标识和调用方式;将从接口数据库中所查询到的该接口标识对应的调用方式确定为所述目标接口的调用方式。 [0113] However, as a preferred embodiment, determining the target invocation interface may be W is based on the interface identifier, interface identifier information query interface corresponding to the interface from a predetermined database, said interface comprising an interface identification information and call mode; in the database queries from the interface to the interface corresponding to the identifier is determined as the target invocation interface is called.

[0114] S203 ;根据所述调用方式和所述接口参数,确定所述接口标识对应的目标接口函数的输入参数中的第一参数。 [0114] S203; the first parameter of the input parameter and is called by the interface parameters, determining the corresponding target interface identifier in accordance with the interface function.

[0115] 本发明实施例中,异步调用需客户端脚本在接口参数中携带一个标识回调函数的参数,为方便描述,将标识回调函数的参数称为预设参数。 Embodiment [0115] embodiment of the present invention, the client-side script for an asynchronous call carries a parameter identifying the interface parameter in the callback function for convenience of description, the parameter identifies the callback function is called preset parameters. 例如,可W将异步调用的接口参数中的最后一个参数用来存放预设参数,当然,也可W根据预先约定设置预设参数在接口参数中的其它位置,具体的,本发明实施例不作限制。 For example, W can be the last asynchronous call interface parameters used to store the default parameters, of course, W may be pre-agreed according to preset parameters provided elsewhere in the interface parameters, in particular, embodiments of the present invention is not limit. 在一种实现方式中,若确定出调用方式为异步调用,获取接口参数中标识回调函数的预设参数,将回调信息保存至预设的回调数据库中,所述回调信息包括所述请求标识和所述预设参数所标识的回调函数,当然,回调信息还可W包括运行该回调函数时所需的环境变量等其它信息,具体的,本发明实施例不作限制。 In one implementation, if it is determined that it is asynchronous mode call, obtaining interface parameters preset parameters identified callback, the callback information will be saved in the database to a predetermined callback, the callback request including said identification information and the preset parameters identified by the callback function, of course, W callback information may also include other information required to run the callback environment variables, specifically, the embodiments of the present invention is not limited. 从而,方便后续步骤(例如,步骤S208)返回异步调用的调用结果时,根据调用目标接口函数后返回的输出参数中的请求标识,从该回调数据库中查询该请求标识对应的目标回调函数。 Therefore, when convenient subsequent step (e.g., step S208) to return the result of calling an asynchronous call, according to the output parameters returning to the calling function in the target interface request identifier, a query identifier corresponding to the request from the callback function of the callback target database.

[0116] 作为一种示例,表示同步调用和异步调用的脚本可W如上述实施例中的代码1所示。 [0116] As an example, a script indicates synchronous and asynchronous calls may be calls W as shown in the above Example 1 code. 可知,同步调用的接口参数均为目标接口对应的目标接口函数所需要的参数,异步接口的接口参数中用来表示回调函数的预设参数(caUback)在目标接口对应的目标接口函数中不需要,但在目标接口函数运行完毕后,需要调用该预设参数所表示的回调函数,返回调用结果。 Found, port Parameter, synchronous asynchronous interface interface parameters are call destination interface corresponding target interface function required to represent the preset parameters callback function (caUback) need not be the target destination interface corresponding to the interface function but after the target interface function has finished running, you need to call the callback function preset parameters indicated, return the result of calling. 本发明实施例中,根据目标接口的调用方式和接口参数来确定目标接口对应的目标接口函数的输入参数中的第一参数。 Embodiment of the present invention, a first parameter to determine the input parameters of the target destination interface corresponding to the interface function is called by the target in accordance with the interface and the interface parameters. 具体实现中,若调用方式为同步调用,将接口调用请求中携带的接口参数确定为目标接口对应的目标接口函数的输入参数中的第一参数;若调用方式为异步调用,将接口调用请求携带的接口参数中除预设参数外的其它参数确定为目标接口函数的输入参数中的第一参数,其中,预设参数用于标识回调函数,每个预设参数对应一个回调函数。 In specific implementation, if a call for the synchronous call, the call carried in the request interface interface parameters determined as the first input parameter corresponding to the interface parameters of the target function in the target interface; if the call mode is an asynchronous call interface call request carries Interface parameters other parameters outside the preset parameters of the first parameter is determined as a function of the input parameters of the target in the interface, wherein the preset parameter identifies the callback function, each parameter corresponding to a predetermined callback function.

[0117] S204;将所述第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型。 [0117] S204; the first parameter format conversion, data type of the first parameter after conversion into a second predetermined data type.

[0118] 由于目前的浏览器大多为多核浏览器,即浏览器中包括两个或两个W上的浏览器内核,现有方法在针对多核浏览器开发扩展接口时,需针对每一种浏览器内核都设计一个与该扩展接口所要实现的功能相同的接口函数,不仅开发成本高,而且由于不同的浏览器内核对接口函数的设计规范不一样,不同的浏览器内核针对相同的接口标识所调用的接口函数不同,导致接口调用流程复杂,从而,调用接口的效率低。 [0118] Since most current browser polynuclear browser, the browser i.e. the browser includes a kernel on two or W, when the conventional methods for multi-core browser development expansion interface, the need for every browser cores are designed for a same function as the interface functions of the expansion interface to be achieved, not only the development of high costs, but also due to the design specifications of different browser kernel interface function is not the same, different browser kernel for the same interface that identifies the different interface function calls, resulting in an interface call flow complexity, thus, low call interface efficiency.

[0119] 本发明实施例中,将接口函数的设计规范化,不管针对什么样的浏览器内核,均采用相同的规范来设计接口函数。 [0119] embodiment of the present invention, the standardized design interface function, no matter what kind of browser for the core, are designed using the same standardized interface functions. 例如,接口函数的设计规范可W如代码2所示,在添加接口函数时,开发人员只需根据该规范来实现相应的功能即可。 For example, interface functions can design specifications as shown in the code W 2, when adding interface functions, developers need to implement corresponding functions can according to this specification. 值得说明的是,代码2仅为示例,本发明并不限于该示例。 It should be noted that the code 2 is merely exemplary, the present invention is not limited to this example.

[0120] //接口函数规范,id表示与接口调用请求对应的请求标识,kv_map保存脚本传入的参数 [0120] // interface function specifications, id represents the interface call request identifier corresponding to the request, kv_map save the script parameters passed

[0121] ValueInterfaceFunction(intid,KeyValueMapkv_map); [0121] ValueInterfaceFunction (intid, KeyValueMapkv_map);

[0122] 在该规范中,id为请求标识,用于跟踪该接口调用请求及调用结果;接口函数的第一参数kv_map的数据类型为预设的第二数据类型,所述第二数据类型可W是预先定义的用于接纳任何类型数据的数据结构类型,也可W是编程语言自带的数据库中的通用数据类型,该数据类型可W接收任何数据类型的数据。 [0122] In this specification, id is a request identifier, a request for tracking interface call and calls the results; kv_map first parameter data type interface functions for the preset second data type, said second data type W is a predefined data structure for receiving any type of data type, W may be a general purpose programming language built data types in the database, the data type W may receive any data type. 例如;KeyValueMap类型或Value 类型,具体的,本发明实施例不作限制。 For example; KeyValueMap Value type or types, specific, embodiments of the present invention is not limited. 为方便说明,本发明实施例W第二数据类型为K巧ValueMap类型为例,但应当说明的是,并不限制第二数据类型为K巧ValueMap类型。 For convenience of illustration, embodiments of the present invention the second data type is W K clever ValueMap type, for example, it should be noted that the second data type is not limited clever ValueMap K type. 其中,KeyValueMap或Value是一种数据类型,该类型像储物箱一样,可W用来保存多种不同类型的数据,例如;整数、浮点数、字符串等等。 Wherein, KeyValueMap or Value is a data type that like the storage box as W can be used to hold a plurality of different types of data, for example; an integer, float, string and the like. 具体的,KeyValueMap是一种键-值化ey-Value)映射表,该映射表中保存了键化ey)和值(Value)的一一对应关系,键化ey) 可W是数字(参数的顺序)或字符串(参数的名称),值(Value)是参数中对应某个键的具体值。 Specifically, KeyValueMap a key - the value of ey-Value) mapping table, the mapping table stored in the key of EY) and value (Value) of one relationship, the key of the EY) W can be numbers (parameters order) or string (name of the parameter), the value (value) is a parameter corresponding to the value of a specific key.

[0123] 本发明实施例中,将所确定的第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型。 [0123] Example embodiments of the present invention, the first parameter determined format conversion, data type of the first parameter after conversion into a second predetermined data type. 即在调用目标接口对应的目标接口函数前需要把脚本传递进来的第一参数进行转换,如将第一参数转换成一个KeyValueMap对象等。 The first parameter that is passed in the script needs to call the target interface before the interface corresponding target conversion function, as will be converted into a first parameter KeyValueMap objects.

[0124] 为方便说明,假设客户端脚本欲调用一个添加网页历史记录的接口,且该接口的调用方式为异步调用,则客户端脚本提供的接口规范可W为:化nctionrecor地istcxry (url,date,caUback),第一个参数表示需要传入网页的网址(url,假定为ht化:\\w丽. liebao.cn),第二个参数表示需要传入访问的时间(time,假定为2014-07-2020:00:00), 最后一个参数为脚本函数对象,该参数不作为调用接口函数的参数,而用于在接口函数操作成功后通知脚本,因此,步骤S103根据接口参数所确定的第一参数不包括将该参数。 [0124] For illustrative purposes, assume that the client script To call a Add Web History interface, and call the way the interface is asynchronous call, the client script provides the interface specification can be W is: of nctionrecor to istcxry (url, date, caUback), the first parameter expressed the need for URL into a web page (url, assumed ht of:. \\ w Li liebao.cn), the second parameter indicates the need for incoming access time (time, assumed to be 2014-07-2020: 00: 00), the last parameter is a function object script, the call interface parameter does not function as an argument, and the operation is successful for the notification script interface function, therefore, step S103 is determined in accordance with the interface parameter the first parameter is not included parameters. 将所确定的第一参数进行格式转换后,得到转换后的KeyValueMap类型的第一参数可W如表2所示,表2是本发明实施例提供的一种第二数据类型的示意。 After the determined first parameter format conversion to obtain a first parameter type may be converted KeyValueMap W are as shown in Table 2, Table 2 is a schematic of a second data type according to an embodiment of the present invention.

[0125]表2 [0125] TABLE 2

[0126] [0126]

Figure CN104866383AD00131

[0127] 从而,保证不同的浏览器内核接收到客户端脚本的接口调用请求后,均可W通过本步骤将第一参数转换为数据类型相同的参数,对接口函数的输入参数的数据类型实现了统一,因此,开发人员针对多核浏览器开发一套接口时只需设计一个接口函数。 After [0127] Accordingly, to ensure that a different browser invocation request received by the core scripting interface client, W may be present by a first step of converting the same data type parameter to the parameter data type interface functions of the input parameters to achieve a unified, therefore, when a developer for developing a multi-core browser interface requires only one interface design function.

[0128]S205;将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数。 [0128] S205; requested the interface call request identifies the first parameter and the interface function as the target of the input parameters, the target interface function call.

[0129] 具体实现中,在将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数之前,可W确定所述接口调用请求的请求标识。 [0129] In a specific implementation, the interface in the invocation request and the request identifier as an input parameter to the first parameter of the interface function of the target, the target interface before calling the function, W may determine that the interface call request request ID. 考虑到浏览器在加载网页的过程中,会存在同时处理多项接口调用请求的情况,因此,采用请求标识来标定客户端脚本调用接口的每项接口调用请求,该请求标识与其对应的接口调用请求的所有信息关联,所述信息包括该接口调用请求的接口标识、接口参数、调用结果等,从而,通过请求标识来跟踪每项接口调用请求及调用结果。 Taking into account the browser while loading the page, there will be simultaneous handling of multiple interface call request, therefore, the use of the identification request to calibrate each interface calls the request script calls the interface of the client, the request identifies the corresponding interface calls All related information request, said information including an interface identifier of the interface call request, the interface parameters, like the call, so that, by tracking each request identifies the request and calls the interface call results. 本发明实施例中,接收到接口调用请求后,确定该接口调用请求的请求标识,其中,请求标识可W是浏览器内核接收到接口调用请求时自动分配的。 After embodiments of the present invention, the interface invocation request is received, it is determined that the interface call request identifies the request, wherein the request identifies a kernel may be W is received by the browser automatically assigned when the interface invocation request. 可知,一个请求标识唯一标定一项接口调用请求,且请求标识与该项接口调用请求所携带的接口标识和接口参数关联。 Shows that a request identifies a unique calibration interface call request, and the request interface identification and interface parameters associated with the identification request interface calls carried.

[0130] 通常,开发人员开发出一套扩展接口后,将该接口的相关信息保存在预设的接口数据库中,其中,接口的相关信息包括接口标识和接口函数,所述接口标识可W是接口名称。 [0130] Generally, a rear set of developers expansion interface, the interface information stored in the default database in the interface, wherein the interface includes information identifying interfaces and interface function, the interface identification may be W is interface name. 若开发人员已提供了接口调用请求所指定的目标接口,则由接口调用请求中携带的接口标识可W在预设的信息库中查找到一个唯一的与该接口标识匹配的接口函数。 If the developer has provided interface calls requesting the designated target interface by interface call request carries an interface identifier W may find a unique interface function that matches the interface identifier in pre repository. 本发明实施例中,根据接口调用请求中携带的接口标识,查询接口数据库中是否存在与所述接口标识匹配的接口函数。 Embodiments of the present invention, the interface according to the interface identifier carried in the call request, the database query interface function of whether there is an interface with the interface identification match. 若存在,说明浏览器提供该接口标识所指定的目标接口,根据接口调用请求对应的请求标识和转换后的第一参数运行所查找到的目标接口函数;若不存在,说明浏览器不提供该目标接口,则返回预设的错误信息。 If present, the browser provides the described interface identifier specified target interface, a first operating parameter corresponding to the request after the request ID and the interface call according to the searched target interface function; if not, the browser does not provide the description target interface, the default error message is returned.

[0131] 若查询到接口数据库中存在与接口标识匹配的目标接口函数,则将请求标识和步骤S204中转换后的第一参数作为所查找到的目标接口函数的输入参数,调用该目标接口函数。 [0131] If the query interface to the database with the presence of matched target interface identifier interface function, then the input parameters of the first parameter as the identification step S204 and converting the found target request interface function, the interface function call to the object . 换句话说,将请求标识和转换后的第一参数代入所查找到的目标接口函数中,运行或执行所查找到的目标接口函数。 In other words, after the first request ID and the parameters into the found target interface function, operation, or to perform the lookup target interface function. 从而,针对不同的浏览器内核,采用本发明实施例后,可W 采用统一的规范调用接口函数,不同的浏览器内核调用接口的方式相同,调用接口的效率高,网页的执行效率也得到提高。 Thus, for different browser kernel, using the embodiment of the present invention, it may be W unified standardized call interface function, the same different browser kernel call interface manner, a high call interface efficiency, the efficiency of the page has also been improved .

[0132] S206;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数,所述输出参数的数据类型为预设的第一数据类型。 [0132] S206; output parameter obtaining the target interface returning to the calling function, the output parameter comprises the request identification and the second parameter, the output parameter data type is a first predetermined data type.

[0133] 调用目标接口对应的目标接口函数后,获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数,所述输出参数的数据类型为预设的第一数据类型,其中,第二参数用来表示目标接口函数的运行结果。 [0133] After the call target interface function corresponding to the target interface, obtain the output parameters of the target interface returning to the calling function, the output parameter comprises the request identifies the second parameter and the data type of the output parameter is a preset a first data type, wherein the second parameter is used to indicate certain operating results interface functions. 具体实现中,所述第一数据类型可W是预先定义的用于接纳任何类型数据的数据类型,也可W是编程语言自带的数据库中的通用数据类型,该数据类型可W接收任何数据类型的数据。 In specific implementation, the first data type may be W is a predefined data type for receiving any type of data, may be W is a programming language built common data types in the database, the data type can receive any data W types of data. 例如;KeyValueMap类型或Value类型,具体的,本发明实施例不作限制。 For example; KeyValueMap Value type or types, specific, embodiments of the present invention is not limited. 为方便说明,代码2或本发明实施例中W第一数据类型为Value类型为例,但本发明实施例并不限制第一数据类型为Value类型。 For the convenience of explanation, a first embodiment W Case Type Value data type or embodiment of the present invention, code 2, but the present invention is not limited embodiment of a first type of data type Value. 从而,开发人员针对不同的浏览器内核开发扩展接口时,只需根据规范设计一个接口函数, 无需针对不同的浏览器内核分别设计一个接口函数,且无需设计该接口函数对应的接口的调用方法,不仅可W减少开发成本,而且提高开发效率。 Thus, developers of browsers for different kernel development expansion interface, a design interface function only according to the specification, without the kernel for each different design of a browser interface function calls the interface method corresponding to the interface function and without design, W can not only reduce development costs, and improve development efficiency.

[0134] 值得说明的是,在具体实现中,也可W是第二参数的数据类型为预设的第一数据类型,接口函数的输出参数的数据类型为结构体,该结构体包括请求标识和第二参数。 [0134] It should be noted that, in the particular implementation, W can also be a data type of the second parameter is a first predetermined data type, the data type of the output parameter as a function of the interface structure, the structure comprising a request identifier and the second parameter. 例如,W第一数据类型为Value类型为例,结构体的规范可W如代码3所示。 For example, a first data type Value W type, for example, the structure may be standardized codes W 3 as shown.

[01巧]代码3 [Qiao 01] Code 3

[0136]structInterfaceResult [0136] structInterfaceResult

[0137] { [0137] {

[013引Valueval; [013 cited Valueval;

[0139]intid; [0139] intid;

[0140] }; [0140]};

[0141]S207;将所述第二参数进行格式转换,转换后的第二参数的数据类型为预设的第S数据类型。 [0141] S207; the second parameter format conversion, data type of the second parameter after conversion to the preset first data type S.

[0142]作为一种优选的实施方式,将所获取到的调用目标接口函数后返回的输出参数中的第二参数进行格式转换,转换后的第二参数的数据类型为预设的第=数据类型。 [0142] As a preferred embodiment, the second parameter output parameter returns the call to the acquired target interface function of format conversion, data type of the second parameter after conversion to the preset first data = Types of. 其中,第=数据类型可W是预先定义的用于接纳任何类型数据的数据结构类型,也可W是客户端脚本语言中的通用数据类型,例如,化ject对象,具体的,本发明实施例不作限制。 Wherein the first data type = W is a pre-defined data structure for receiving any type of data type, W may also be a general data type client-side scripting language, e.g., ject of the object, particularly, embodiments of the present invention no restrictions. 从而,对返回给客户端脚本的调用结果进行规范化处理,提高脚本的执行效率。 Thus, to return to the client script calls the results of the standardization process, improve the efficiency of the script. 值得说明的是,也可W 不针对第二参数进行格式转换,跳过本步骤而执行步骤S208。 It should be noted that W can not performing format conversion for a second parameter, skip this step goes to the step S208.

[014引S208;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [014 cited S208; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script.

[0144]根据目标接口的调用方式,将第二参数作为该输出参数中的请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0144] The target interface is called, the second parameter as a result of calling the call request of the output parameter corresponding to the identifier of the request to return the interface to the client script. 具体实现中,若目标接口的调用方式为同步调用,将第二参数或经格式转换后的第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本;若所述调用方式为异步调用,根据所述请求标识,确定该请求标识对应的目标回调函数,将第二参数或经格式转换后的第二参数作为所述目标回调函数的输入参数,运行所述目标回调函数得到输出结果,进而将所述输出结果作为所述接口调用请求的调用结果返回给客户端脚本。 In specific implementation, if the target invocation interface is a synchronous call, the second parameter or the second parameter format-converted, as the result of the call request to invoke the requested interface corresponding to the identifier is returned to the client script; if the said asynchronous invocation is called, according to the request identifies the target, determine that the request identifies a corresponding target callback function, the second parameter or a second parameter as an input parameter format converted callback function of the target, running callback function to obtain an output result, and further outputs the result as the interface call requesting the call returns to the client script.

[0145]在一种实施例中,若调用方式为异步调用,则确定所述请求标识对应的目标回调函数的方式可W是;根据所述请求标识,从所述回调数据库中查询所述请求标识对应的回调信息;将所述回调信息指定的回调函数确定为目标回调函数。 [0145] In one embodiment, when the call mode is an asynchronous call, it is determined that the request identifies the callback object corresponding manner is W; identifier according to the request, query the database from said callback request correction corresponding to the identification information; information specifying the callback function of the callback function is determined as the target callback. 同时,若获取到该回调信息中存储有运行该目标回调函数的其它信息,则根据该些信息设置当前的环境变量,保证正常运行该目标回调函数,将调用结果通知给客户端脚本。 Meanwhile, if the callback to get the information stored in other target information to run the callback function, the information set environment variables based on the current more, to ensure the normal operation of the target callback function will be called result to client-side scripting.

[0146]作为一种可行的实施方式,将调用结果返回给客户端脚本后,删除所述回调数据库中所述请求标识对应的回调信息。 After [0146] In a feasible embodiment, the call returns to the client-side script, remove the callback request callback information identifying the corresponding database. 从而,降低数据量,提高目标回调函数的查询效率。 Thus, reducing the amount of data, improve query efficiency goals callback function.

[0147]在本发明实施例描述的接口调用方法中,接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数; 将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0147] In the interface method invocation described in the present embodiment of the invention, the invocation request reception interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target interface to the browser one extension provided by the interface; the interface according to the identifier, determining a target invocation interface; a first parameter of the input parameters of the target and is called by the interface parameters, determining the target function corresponding to the interface in accordance with the interface ; request the interface call request identifies the first parameter and the interface function as the target of the input parameters, the interface function call to the target; output parameter obtaining the target interface returning to the calling function, said output parameter the request includes identification and the second parameter; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用, 浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数,提高开发效率。 Whereby, when the expansion interface developers, the ability to develop the expansion interface corresponding to the interface function, to improve development efficiency.

[0148] 下面为本发明装置实施例,本发明装置实施例与本发明方法实施例属于同一构思,用于执行本发明方法实施例中描述的方法。 [0148] The following embodiment of the apparatus of the present invention, apparatus according to the present invention belong to the same embodiment of the present invention and methods contemplated embodiment, the method for performing the method described in the embodiment of the present invention. 为了便于说明,本发明装置实施例仅示出与本发明装置实施例相关的部分,具体技术细节未揭示的,请参照本发明方法实施例的描述, 此处不再一一寶述。 For convenience of explanation, the present invention apparatus embodiment shows only part related to the embodiment of the present invention, the technical details are not disclosed, please refer to the method described in the embodiments of the invention, not going to be described later herein Po.

[0149] 请参见图3,图3是本发明实施例提供的一种接口调用装置的结构示意图,在本发明实施例中,该装置可W包括;接收模块101、方式确定模块102、参数确定模块103、调用模块104、获取模块105和返回模块106。 [0149] Referring to FIG. 3, FIG. 3 shows the structure of a device interface calls to an embodiment of the present invention, in the embodiment of the present invention, the apparatus may comprise W; a receiving module 101, a mode determining module 102, parameter determination module 103, a calling module 104, an obtaining module 105 and module 106 returns.

[0150] 接收模块101,用于接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口中的任一扩展接口。 [0150] The receiving module 101, configured to receive a request for calling the interface, the interface call request carries the destination interface and the corresponding interface identifier with a client-side script interface parameters need to call the target interface in the extended interface provided by browser any one of the expansion interface.

[0151] 方式确定模块102,用于根据所述接口标识,确定所述目标接口的调用方式。 [0151] mode determining module 102, based on the interface identifier for determining the target invocation interface.

[0152] 参数确定模块103,用于根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数。 [0152] parameter determination module 103, according to the call mode and the interface parameters, determining a first parameter of the input parameter corresponding to the target interface in the objective function of the interface.

[0153] 调用模块104,用于将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数。 [0153] invoking module 104, configured to interface call request identifies the request as an input parameter and the first parameter of the interface function of the target, the target interface function call.

[0154] 获取模块105,用于获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数。 [0154] 105 acquisition module, for acquiring the output parameter returns the call to the target interface function, the request comprising the identifier output parameter and the second parameter.

[0155] 返回模块106,用于基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0155] returning module 106, based on the second parameter, the call request corresponding to the identification result of the call to the interface request is returned to the client script.

[0156] 在本发明实施例描述的接口调用装置中,接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数; 将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0156] In the device interface calls described embodiment of the present invention, the received call request interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target interface to the browser one extension provided by the interface; the interface according to the identifier, determining a target invocation interface; a first parameter of the input parameters of the target and is called by the interface parameters, determining the target function corresponding to the interface in accordance with the interface ; request the interface call request identifies the first parameter and the interface function as the target of the input parameters, the interface function call to the target; output parameter obtaining the target interface returning to the calling function, said output parameter the request includes identification and the second parameter; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用, 浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数,提高开发效率。 Whereby, when the expansion interface developers, the ability to develop the expansion interface corresponding to the interface function, to improve development efficiency.

[0157] 请参见图4,图4是本发明实施例提供的一种接口调用装置的另一结构示意图,在本发明实施例中,该装置可W包括;接收模块201、方式确定模块202、参数确定模块203、调用模块204、获取模块205、返回模块206、第一转换模块207、第二转换模块208、保存模块301和删除模块302。 [0157] Referring to FIG. 4, FIG. 4 is another schematic structure of a device interface calls according to an embodiment of the present invention, in the embodiment of the present invention, the apparatus may comprise W; receiving module 201, a mode determining module 202, parameter determination module 203, a calling module 204, an obtaining module 205, module 206 returns, the first conversion module 207, a second conversion module 208, storage module 301 and deleting module 302.

[015引接收模块201,用于接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之0 [015 primer receiving module 201, configured to receive a request for calling the interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target interface in the extended interface provided by the browser 0

[0159] 方式确定模块202,用于根据所述接口标识,确定所述目标接口的调用方式。 [0159] mode determining module 202, according to the interface identification, is called to determine the target interface.

[0160] 参数确定模块203,用于根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数。 [0160] parameter determination module 203, a first parameter of the input parameter and is called by the interface parameters, determining the target destination interface corresponding to the interface function in accordance with.

[0161] 调用模块204,用于将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数。 [0161] calling module 204, the interface call request identifies the first request and a parameter for the interface as an input parameter of the target function, the target interface function call.

[0162] 获取模块205,用于获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数。 [0162] 205 acquisition module, for acquiring the output parameter returns the call to the target interface function, the request comprising the identifier output parameter and the second parameter.

[0163] 返回模块206,用于基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0163] Back module 206, based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script.

[0164] 在一种实施例中,所述输出参数的数据类型为预设的第一数据类型。 [0164] In one embodiment, the data type of the parameter to output a first predetermined type of data.

[0165] 第一转换模块207,用于将所述第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型。 [0165] first conversion module 207, the first parameter for the format conversion, data type of the first parameter after conversion into a second predetermined data type.

[0166] 第二转换模块208,用于将所述第二参数进行格式转换,转换后的第二参数的数据类型为预设的第=数据类型。 [0166] The second conversion module 208, the second parameter for the format conversion, data type of the second parameter after conversion to the preset type of data =.

[0167] 保存模块301,用于若所述调用方式为异步调用,将回调信息保存至回调数据库中,所述回调信息包括所述请求标识和所述预设参数所标识的回调函数。 Save [0167] storage module 301, if the calling mode is for asynchronous call, the callback to the callback information in the database, the correction information request comprises the identifier and the preset parameters identified by the callback function.

[0168] 删除模块302,用于删除所述回调数据库中所述请求标识对应的回调信息。 [0168] deleting module 302, for deleting said callback request a callback information of the database corresponding to the identifier.

[0169] 在另一种实施例中,参数确定模块203具体用于: [0169] In another embodiment, the parameter determination module 203 is specifically configured to:

[0170] 若所述调用方式为同步调用,将所述接口参数确定为所述目标接口函数的输入参数中的第一参数; [0170] If the call mode is a synchronous call, the interface parameters determined as the first parameter of the input parameter in the objective function interfaces;

[0171] 若所述调用方式为异步调用,将所述接口参数中除预设参数外的其它参数确定为所述目标接口函数的输入参数中的第一参数,所述预设参数用于标识回调函数。 [0171] If the call mode is an asynchronous call, to determine the interface parameters preset parameters other parameters except for the first parameter of the object parameter input interface functions in the preset parameters for identifying Callback.

[0172] 在另一种实施例中,返回模块206包括:同步返回单元2061和异步返回单元2062,如图4a所示,图4a是图4提供的其中一种返回模块的结构示意图。 [0172] In another embodiment, the return module 206 includes: a synchronization return unit 2061 and the asynchronous return unit 2062, shown in Figure 4a, 4a is one of the return module 4 provides a schematic view of the structure of FIG.

[0173] 同步返回单元2061,若所述调用方式为同步调用,将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本; [0173] synchronization return unit 2061, if the invocation is synchronous calls, the second parameter as a result of the call request to invoke the requested interface corresponding to the identifier is returned to the client script;

[0174] 异步返回单元2062,若所述调用方式为异步调用,确定所述请求标识对应的目标回调函数,并将所述第二参数作为所述目标回调函数的输入参数,运行所述目标回调函数得到输出结果,进而将所述输出结果作为所述接口调用请求的调用结果返回给客户端脚本。 [0174] Induction return unit 2062, when the calling mode is an asynchronous call, determining a corresponding target request identifies the callback function, and the second parameter as an input parameter of the callback function of the target, the target operating callback function to get the output, and then outputs the result as the interface call requesting the call returns to the client script.

[0175] 在另一种实施例中,同步返回单元2061具体用于; [0175] In another embodiment, particularly for the synchronization return unit 2061;

[0176] 根据所述请求标识,从所述回调数据库中查询所述请求标识对应的回调信息; [0176] identifier according to the request, the query request corresponding to a callback information identifying the callback from the database;

[0177] 将所述回调信息指定的回调函数确定为目标回调函数。 [0177] Specifies the callback function callback information is determined as the target callback function.

[0178] 在另一种实施例中,方式确定模块202具体用于; [0178] In another embodiment, the mode determining module 202 is configured;

[0179] 根据所述接口标识,从预设的接口数据库中查询所述接口标识对应的接口信息, 所述接口信息包括接口标识和调用方式; [0179] The said interface identifier, interface identifier of the interface information corresponding to the query from the default database interfaces, the interface information includes an interface identifier and a call mode;

[0180] 将所述接口数据库中该接口标识对应的调用方式确定为所述目标接口的调用方式。 [0180] The determination of the target invocation interface in the interface to the database to identify the corresponding interface is called.

[0181] 在本发明实施例描述的接口调用装置中,接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数; 将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0181] In the device interface calls described embodiment of the present invention, the received call request interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target interface to the browser one extension provided by the interface; the interface according to the identifier, determining a target invocation interface; a first parameter of the input parameters of the target and is called by the interface parameters, determining the target function corresponding to the interface in accordance with the interface ; request the interface call request identifies the first parameter and the interface function as the target of the input parameters, the interface function call to the target; output parameter obtaining the target interface returning to the calling function, said output parameter the request includes identification and the second parameter; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用, 浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数,提高开发效率。 Whereby, when the expansion interface developers, the ability to develop the expansion interface corresponding to the interface function, to improve development efficiency.

[0182] 请参见图5,图5是本发明实施例提供的一种接口调用装置的又一结构示意图,在本发明实施例中,该装置可W包括;参数转换器301、接口代理302、接口转发器303、接口通知器304、接口注册器305、接口数据库306和调用请求数据库307。 [0182] Referring to FIG. 5, FIG. 5 is a diagram showing still another structure of an interface call apparatus according to an embodiment of the present invention, in the embodiment of the present invention, the apparatus may comprise W; parameter converter 301, an interface agent 302, Interface repeater 303, the interface 304 notifies the interface register 305, a database interface 306 and database 307 invocation request.

[018引具体实现中,若接口调用指令所指定的目标接口的调用方式为异步调用,则该接口调用装置还可W包括回调数据库308和回调器309。 [018 primers specific implementation, called by the interface when the target interface specified by the call instruction is an asynchronous call, the call to the interface device may further include a correction database 308 W and 309 callbacks. 开发人员在添加接口时,需要向接口注册器305提供接口的接口标识和调用方式等注册信息,为方便说明,假定接口标识为接口名称,其中,接口函数的具体实现在主进程中提供。 When you add an interface developer is required to provide an interface to the interface registers 305 interface identification and registration information call mode, etc., for the convenience of explanation, assume that the interface identifier for the interface name, which implement specific interface functions provided in the primary process. 接口注册器305记录该些注册信息,并在浏览器创建擅染进程后,把该些注册信息通过进程间通信的方式发送给擅染进程, 擅染进程把该些注册信息缓存在接口数据库306中,从而,接口数据库306中记录有各接口的接口信息,例如,接口数据库的存储形式可W如表1所示。 After recording the plurality of registration information interface registration 305, and create good at dyeing process in the browser, to the plurality of registration information sent through inter-process mode of communication to the good at dyeing process, good dyeing process to the plurality of registration information is cached in a database interface 306 thereby, the interface database interface information 306 is recorded in each interface, e.g., the database may be stored in the form of the interface W are as shown in table 1. 回调数据库308用于调用方式为异步调用时,存储该异步调用的请求标识和该请求标识所标定的接口调用请求中携带的回调函数,从而,回调器309可W根据请求标识去回调数据库308中查询该请求标识对应的目标回调函数,通过调用该目标回调函数的方式向脚本返回调用结果。 Database 308 for invoking the callback mode is an asynchronous call, the identifier of the storage request and an asynchronous call request for calling the callback request interface identifier carried in the calibration, and thus, the callback 309 W can be identified according to a callback request database 308 the query request corresponding to the identification of target callback function invocation result is returned to the calling script by way of the objective callback function. 调用请求数据库307用于存储调用的请求标识和调用方式,从而,接口通知器304获取到目标接口函数运行完毕后的输出参数后,根据该输出参数中的请求标识去调用请求数据库307中查询该请求标识对应的调用方式,若为同步调用,则直接将输出参数发送给接口代理302 ;若为异步调用,则将输出参数发送给回调器309。 After the call request and a request identifier 307 is called by a database for storing call, thereby, the interface 304 notifies the acquired destination interface output parameter function operation is completed, based on the output parameters of the request identifier to call the requested query database 307 corresponding to the identifier request is called, if the call is synchronous, the output parameter will be sent directly to the Interface agent 302; if it is asynchronous, output is sent to the callback parameter 309. 值得说明的是,该接口调用装置可W用于单进程的浏览器中,也可W用于多进程的浏览器中,但为方便说明,W多进程的浏览器为例。 Worthy of note is that the browser interface call W device can be used in a single process can also be used for multi-process browser W's, but for the convenience of explanation, W multi-process browser for example.

[0184] 通常,浏览器在运行过程中大多表现为多进程,所述多进程至少包括擅染进程和主进程,其中,擅染进程用于处理网页内容的擅染,主进程用于处理用户界面和管理所有其它的进程等。 [0184] Generally, in the browser during operation most of the performance multi-process, multi-process comprising the transfection tampering process and the main process at least, wherein, good dyeing process for dyeing processing contents to tampering, the main process for processing user interface and manage all other processes and so on. 由于擅染进程只能执行网页,而不能执行其它操作,因此,扩展接口的具体实现(即接口函数的实现)必须在主进程中提供。 Since the dyeing process can only be executed tamper page, but can not perform other operations, therefore, extended implementation of that interface (i.e., interface functions implemented) must be provided in the main process. 为方便说明,假设浏览器在运行过程中启动了擅染进程和主进程,则在实现客户端脚本的接口调用流程中,擅染进程接收客户端脚本的接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口中的任一扩展接口。 For illustrative purposes, assume that the browser starts during operation of trespassing dyeing process and the main process is implemented client-side scripting of call flow interface, good dyeing process interface call request receiving client script, the interface call request carries there needs to call the client-side script target interface identifier and an interface corresponding to the interface parameter, and the target interface is any expansion interface provided by the browser in an expansion interface. 由于擅染进程本身不可W运行目标接口对应的目标接口函数,因此,根据客户端脚本传入的接口标识和接口参数,重新构造接口调用请求,向主进程发送该接口调用请求,从而,由主进程运行该接口调用请求所指定的目标接口函数,并将运行结果返回给擅染进程和/或客户端脚本,实现脚本的调用。 Since the dyeing process itself is not good at operation target W target interface corresponding to the interface function, therefore, according to the client script incoming interface identification and interfaces, reconstructs the call request interface, the interface transmits the call request to the primary process, thus, the main the interface call request process runs the specified target interface function, and returns the results to run good at dyeing process and / or client-side script to achieve the calling script.

[01化]本发明实施例中,参数转换器301接收客户端脚本201的接口调用请求,所述接口调用请求携带有客户端脚本201需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接之一。 [Of 01] embodiment, the parameter converter 301 receives a request for calling a scripting interface client 201 of the embodiment of the present invention, the interface call request carries the target interface identifier and an interface corresponding to the interface parameter required client-side script 201 is called, the target interface is one of the extended access the browser provides. 参数转换器301查询接口数据库306中是否存在该接口标识对应的接口信息,若不存在,则说明接口调用错误,直接返回预设的错误信息;若存在,则确定该接口标识对应的接口名称和该接口标识对应的目标接口的调用方式。 Whether parameter conversion interface information corresponding to the presence of the interface identifier 301 queries the interface database 306, if not, then the interface call error, the preset directly returns an error message; if present, it is determined that the name of the interface and the corresponding interface identifier Called the target interface corresponding interface identifier. 进一步的,根据该调用方式和所述接口参数确定目标接口对应的目标接口函数的输入参数中的第一参数。 Further, the first parameter to determine the target interface input parameter corresponding target interface functions in accordance with the call mode and the interface parameters. 参数转换器301对第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型,例如,IfeyValueMap类型或Value类型。 Parameters of the first parameter converter 301 converts the format of the first data type of the parameter to a second predetermined type of data, e.g., IfeyValueMap Value type or types.

[0186] 接口代理302 (Inte计aceProxy)从参数转换器301处获取接口调用请求所需的调用信息,或者是参数转换器301将调用信息发送给接口代理302,所述调用信息包括接口调用请求的请求标识、接口名称、第一参数和调用方式,若调用方式为异步调用,所述调用信息还包括回调函数。 [0186] Interface Agent 302 (Inte count aceProxy) obtained from the parameter converter 301 information required for call interface call request or the parameter converter 301 transmits the call information to the interface agent 302, requesting the call interface call information comprises the request identifier, the name of the interface, and the first parameter is called, if the call mode is an asynchronous call, the call information further comprises a callback function. 当然,所述请求标识也可W是接口代理302确定的或生成的,具体的,本发明实施例不作限制。 Of course, the request identifies the agent may also be an interface 302 W is determined or generated, particularly, embodiments of the present invention is not limited. 若调用方式为异步调用,则接口代理302根据所获取到的调用信息,将请求标识和与该请求标识对应的回调函数添加至回调数据库308中。 If the call mode is an asynchronous call, the agent 302 interfaces the call based on the acquired information, the database 308 is added to the callback request ID and the request identifier corresponding to the callback function. W便回调器309接收到主进程中的接口通知器304返回的目标接口函数的输出参数后,根据该输出参数中的请求标识从回调数据库308中查询该请求标识对应的目标回调函数。 W after it receives the callback 309 to the output parameters of the target interface functions into the main process 304 notifies the interface returned by the query request identifier identifying the corresponding target callbacks callbacks from database 308 based on the output parameters of the request. 同时,接口代理302向位于主进程中的接口转发器303发送接口调用请求,所述接口调用请求可W如代码4所示。 Meanwhile, interface agent 302 sends a request to the interface call process in the main repeater interface 303, the interface call may request the code W as shown in Fig.

[0187] 例如,若需要调用的目标接口的调用方式为异步调用,假设目标接口的接口名称为recor地isto巧,则客户端脚本调用该目标接口的代码可W为;recor地i story('http:\\www.liebao.cn',' 2014-07-2020:00:00',onRecor地isto;ryDone),可矢口,第一参数包括"http:\\www.liebao.cn、" "2014-07-2020:00:00,"回调函数的函数名称为onRecor地istcxryDone。 [0187] For example, if the invocation target interface need to call is asynchronous or not, assume that the target of the interface to name Recor to isto Coincidentally, the client script calls the target interface code may be W is; Recor the i story ( ' http: \\ www.liebao.cn ',' 2014-07-2020: 00: 00 ', onRecor to isto; ryDone), can Yaguchi, comprising a first parameter "http: \\ www.liebao.cn," " 2014-07-2020: 00:00, function name "callback function is onRecor to istcxryDone. 因此,参数转换器301接收客户端脚本调用目标接口recor地istory的接口调用请求,确定所述接口调用请求的请求标识和所述目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数。 Thus, the parameter converter 301 receives a client request for calling a scripting interface to the target interface recor istory call, determines the request ID and target interface called by the interface call request; interface parameters according to the embodiment and the call, determining a first parameter of the input parameters of the target object corresponding to the interface in the interface function. 参数转换器303对第一参数进行格式转换,格式转换后的第一参数可W如表2所示。 Parameter converter 303 converts the format of the first parameter, the first parameter after the format conversion may be W As shown in Table 2. 接口代理302可W将标识该接口调用请求的请求标识(request_id)、回调函数对象(该里是onRecor地isto巧Done函数)W及正常执行该回调函数所需的环境变量等信息添加到回调数据库308中,保证回调器可W根据回调数据库308中保存的信息将调用结果成功返回给脚本。 W interface agent 302 can request identifier that identifies the interface call request (request_id), callback object (which is in coincidence Done isto be onRecor function) W, and information required for the normal execution of the callback function is added to a callback environment variables database 308, to ensure the success of W callback can return to save the callback script database 308 information according to the result of the call. 同时,接口代理302根据所获取到的调用信息重新构造接口调用请求,并通过进程间通信的方式将该接口调用请求发送给浏览器主进程中的接口转发器303,接口的调用请求可W如代码4所示,该接口的调用请求可W携带请求标识request_ it接口名称inte计ace、第一参数arguments和调用方式synC,其中,第一参数的数据类型为预设的第二数据类型。 Meanwhile, an interface agent 302 based on the acquired configuration information to re-call interface call request, and communicate through inter-process interface call request is sent to the main process in the browser interface to the repeater 303, the request may call interface such as W 4 shown in the code, the interface call request may request identifier W request_ it carries the name of the interface meter inte ace, and a first parameter arguments is called SYNC, wherein the data type of the first parameter is a second predetermined data type.

[0188] 代码4中举例描述了异步接口的调用请求,其中,request_id用来标识接口调用请求,interhce表示要调用目标接口对应的接口标识,arguments是经过参数转换器301 转换后得到的数据类型为预设的第一数据类型的第一参数,sync用来表示目标接口的调用方式。 In [0188] Example 4 describes the Code asynchronous invocation request interface, wherein, to identify the request_id interface call request, interhce target interface indicates to call the corresponding interface identifier, the data type parameter arguments is the result obtained after the converter 301 is converted to preset first parameter of a first type of data, sync is used to indicate the target interface is called.

[0189]代码4 [0189] Code 4

[0190] [0190]

[0191] [0191]

Figure CN104866383AD00201

[019引若需要调用的目标接口为同步接口,则接口调用请求中的参数sync为true,同理,接口代理302通过进程间通信的方式把所构造的接口的调用请求发送给浏览器主进程中的接口转发器303。 [Primers if desired target interface 019 call is synchronous interface, the interface call parameters for a sync request is true, Similarly, the interface between the agent 302 processes the call interface communicatively constructed of a request sent to the browser main process Interface repeater 303. 若调用方式为同步调用,则接口代理302向接口转发器303发送调用请求后,接口代理302会暂停执行,直到浏览器主进程执行完成并传递返回值后才继续。 If a call for the synchronous call, the interface agent 302 is sent to the interface repeater 303 after the call request, the interface agent 302 will be suspended until the completion of the main browser process execution and pass the return value before continuing. 若调用方式为异步调用,则接口代理302向接口转发器303发送调用请求后,接口代理302会立即返回,从而,擅染进程可W继续执行其它操作,网页的执行效率高。 If the invocation is asynchronous call, the interface 303 sends calls to the agent 302 interface to forward requests, interface agent 302 will return immediately, so, good dyeing process can continue with the implementation of high efficiency W other operations, web pages.

[0193] 接口转发器303接收到接口代理发送的调用请求后,根据该调用请求中所携带的调用信息,将标识该调用请求的请求标识和调用方式添加至调用请求数据库307中,从而, 位于主进程中的调用请求数据库307保存有各请求标识与调用请求所指定的目标接口的调用方式之间的对应关系。 Add the [0193] interface to the repeater 303 receives the call request interface agent sends, in accordance with call information of the call request is carried in, the identifier of the call request requests identification and invocation to invocation request database 307, thereby, located the main call process request database 307 stores correspondence between each of the requests is called the target interface identifier specified by the invocation request. 接口转发器303根据接口标识去接口注册器305中查询与该接口名称对应的目标接口函数,获取目标接口对应的目标接口函数401的位置,将请求标识request_id和第一参数arguments作为所查询到的目标接口函数401的输入参数,调用该目标接口函数,其中,目标接口函数的实现方式可W是异步实现方式也可W是同步实现方式。 The interface 303 interfaces the repeater identifier to query the interface registry 305 interface name that corresponds to the target interface function, obtains the position corresponding to the target interface 401 to the target interface function, the request identifies the first and request_id parameters as arguments to the query destination interface function 401 of the input parameters, the interface function call to the target, wherein the target interface implementation function may be asynchronous implementations W W may be synchronized implementation.

[0194] 通常,接口函数运行完毕后,需要返回运行结果,如操作是否成功,要求读取的数据等等,该些数据为接口函数的输出参数,该输出参数的数据类型为预设的第一数据类型, 如KeyValueMap类型或Value类型等。 [0194] Generally, the interface function has finished running, needs to return to the operation result, as the operation is successful, requires data reading, etc., the plurality of output parameter data interface function, the data type of the output parameter is a preset first a data type, such as KeyValueMap Value type or types. 那么,目标接口函数在执行完毕后,会把输出参数传递给接口通知器304,其中,输出参数包括请求标识和第二参数,第二参数为所述请求标识对应的接口调用请求的调用结果,从而,接口通知器304根据请求标识在调用请求数据库307中查找所对应的调用请求和调用方式。 Then, the objective function after the implementation of the interface, the interface will pass parameters to an output notification 304, wherein the output parameters include a request identifier and a second parameter, the second parameter is the result of calling the interface invoking request to the request corresponding to the identifier, thus, the interface 304 notifies the call request according to the request identifier database 307 lookup call request and call the corresponding manner.

[01巧]若调用方式为同步调用,则接口通知器304将请求标识和第二参数发送给接口代理302,从而,接口代理302接收到接口通知器304返回的目标接口函数的输出参数后,继续执行其它操作。 [Qiao 01] When called by a synchronous call, the interface 304 notifies the request identification and the second parameter to the interface agent 302, thus, interface agent then outputs the target interface function 302 receives a notification 304 to the interface returned, continue to perform other operations. 参数转换器301对输出参数中的第二参数进行格式转换,转换后的第二参数的数据类型为预设的第=数据类型,例如,脚本内部的化ject对象,进而,返回该请求标识对应的调用结果给脚本,同步调用完成。 Parameter converter 301 the output parameter a second parameter format conversion, data type of the second parameter after conversion into the first data type = preset, for example, scripted inside ject objects, and further, returns to the request corresponding to the identifier the result of the call to the script, synchronous call to complete. 在同步调用完成后,根据请求标识删除调用请求数据库307中的对应项,从而降低数据量,提高查询效率。 After the completion of synchronous call, according to call request identifies a request to delete the corresponding entry in the database 307, thereby reducing the amount of data to improve the efficiency of the query.

[0196] 若调用方式为同步调用,接口代理302给接口转发器303发送接口的调用请求后会立即返回,继续执行脚本的其它部分。 [0196] When the call for the synchronous call, the interface agent 302 to the interface 303 sends the repeater interface invocation request returns immediately, continue with the other part of the script. 而调用接口的返回结果需要通过调用请求所指定的回调函数来返回。 Interface call returns the result needs to be returned by the callback function specified in the call request. 因此,接口通知器304根据输出参数中的请求标识从调用请求数据库307中查询得该请求标识对应的目标接口为异步调用后,将请求标识和第二参数发送给擅染进程中的回调器309,回调器309采用该请求标识从回调数据库308中查询该请求标识对应的目标回调函数,同时,调用参数转换器301将第二参数进行格式转换,转换后的第二参数的数据类型为预设的第=数据类型,例如,脚本的化ject对象,将转换后的第二参数作为目标回调函数的输入参数,运行脚本提供的目标回调函数,从而,返回调用结果,异步接口调用完成。 Therefore, the interface 304 notifies the query request to obtain the target database 307 corresponding to the request from the call identification parameters according to an output interface asynchronous call request identifier, a request identifier and a second parameter to the callback 309 tamper transfected Process , 309 using the callback query request identifies the request corresponding to the identifier from a callback function of the callback target database 308, simultaneously, the call parameters of the second parameter converter 301 converts the format type of the second data parameter after conversion to the preset = a first type of data, e.g., the object of ject script, the second converted parameters as input parameters of the target callback, the callback function to run certain scripts provided to return the results of calling, call completion asynchronous interface. 在异步调用完成后,根据请求标识删除调用请求数据库307和回调数据库308中的对应项,从而降低数据量,提高查询效率。 After the completion of asynchronous call, according to call request identifies a delete request database 307 and the corresponding entry in the correction database 308, thereby reducing the amount of data to improve the efficiency of the query.

[0197] 在本发明实施例描述的接口调用装置中,接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数; 将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0197] In the device interface calls described embodiment of the present invention, the received call request interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target interface to the browser one extension provided by the interface; the interface according to the identifier, determining a target invocation interface; a first parameter of the input parameters of the target and is called by the interface parameters, determining the target function corresponding to the interface in accordance with the interface ; request the interface call request identifies the first parameter and the interface function as the target of the input parameters, the interface function call to the target; output parameter obtaining the target interface returning to the calling function, said output parameter the request includes identification and the second parameter; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用, 浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数,提高开发效率。 Whereby, when the expansion interface developers, the ability to develop the expansion interface corresponding to the interface function, to improve development efficiency.

[0198] 请参见图6,图6是本发明实施例提供的一种终端的结构示意图,在本发明实施例中,终端10包括如上所述的接口调用装置。 [0198] Referring to FIG. 6, FIG. 6 is a structural diagram of a terminal according to an embodiment of the present invention, in the embodiment of the present invention, the terminal 10 includes a device interface calls as described above. 在本发明实施例中,所述终端可W包括;智能手机、电脑、平板电脑、笔记本电脑、掌上电脑W及移动互联网设备(MID)、PAD等终端设备。 In an embodiment of the present invention, the terminal may include W; smart phones, computers, tablet computers, notebook computers, handheld computers and mobile Internet W device (MID), PAD and other devices. 具体的,本发明实施例不作限制。 Specifically, embodiments of the present invention is not limited.

[0199] 值得说明的是,终端10包括如上所述的任意一种接口调用装置,该终端接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数;将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0199] It should be noted that, the terminal 10 includes an interface to call any one device as described above, the terminal receives request for calling the interface, the interface call request carries a calling client script needs target interface identifier and an interface corresponding to the interface parameters, the interface is one of the target expansion interface provided by browser; accordance with the interface identifier, determining a target invocation interface; interface parameters according to the embodiment and the call, determining the target destination interface corresponding to the interface after obtaining the target interface function call; a first parameter in the input parameters; identifying said request interface call request and the first parameter as an input parameter of the interface function of the target, the target interface function calls output parameters returned by said output parameter comprises the request identifier and a second parameter; based on the second parameter, the result of invocation request interface call request corresponding to the identifier is returned to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用,浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数, 提高开发效率。 Whereby, when the expansion interface developers, the ability to develop the expansion interface corresponding to the interface function, to improve development efficiency.

[0200] 请参见图7,图7是本发明实施例提供的一种接口调用装置的再一结构示意图, 用于执行本发明实施例公开的接口调用方法,该装置可W包括;至少一个处理器401,例如CPU,至少一个网络接口404或者其他用户接口403,存储器405,至少一个通信总线402。 [0200] Referring to FIG. 7, FIG. 7 is a schematic structural diagram of another call, an interface apparatus according to an embodiment of the present invention, a method for performing call interfaces embodiments disclosed embodiment of the present invention, the apparatus may comprise W; at least one processing 401, a CPU, at least one network interface 404 or other user interface 403, memory 405, at least one communication bus 402. 通信总线402用于实现该些组件之间的连接通信。 Connected to a communication bus 402 for achieving the communication between these components. 其中,用户接口403可选的可W包括USB接口W及其他标准接口、有线接口。 Wherein, the optional user interface 403 may include a USB interface W and W other standard interfaces, cable interfaces. 网络接口404可选的可W包括Wi-Fi接口W及其他无线接口。 Network interface 404 may optionally include a Wi-Fi interface W W and other wireless interfaces. 存储器405可能包含高速RAM存储器,也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。 High-speed memory 405 may include RAM memory, and may also include non-volatile memory (non-volatile memory), for example, at least one disk memory. 存储器405可选的可W包含至少一个位于远离前述处理器401的存储装置。 W memory 405 may optionally comprise at least one storage device is located remotely from the processor 401. 如图7所示,作为一种计算机存储介质的存储器405中可W包括操作系统4051及应用程序4052。 As shown in FIG 7, as a computer memory storage medium 405 may include an operating system 4051 W and 4052 applications.

[0201] 在一些实施方式中,存储器405存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集: [0201] In some embodiments, the memory 405 stores the following elements, executable modules or data structures, or a subset of them, or their expansion set:

[0202] 操作系统4051,包含各种系统程序,用于实现各种基础业务W及处理基于硬件的任务; [0202] Operating system 4051, including various system programs for implementing various basic services and W-based hardware processing tasks;

[0203] 应用程序4052,包含目标网络数据的数据分块参数的设置程序、目标数据块的划分程序、目标数据块与数据库中的数据块的比较程序W及目标数据块的删除程序等各种应用程序,用于实现各种应用业务。 [0203] Application 4052, the target network data comprising data block parameter setting program, the program is divided target block, the target block of data comparison program with program object W and deleting data blocks in the data blocks other database applications used to implement a variety of business applications.

[0204] 具体地,处理器401用于调用存储器405中存储的程序,执行W下操作: Programs [0204] In particular, a call processor 401 stored in the memory 405, the operation performs W:

[0205] 接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一; [0205] invocation request reception interface, the interface call request carries the destination interface and the corresponding interface identifier client script interface parameters need to call one of the extended interface provided by the browser to the target interface;

[0206] 根据所述接口标识,确定所述目标接口的调用方式; [0206] The said interface identifier, is called to determine the target interface;

[0207] 根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数; [0207] According to the invocation and the parameters of the interface, determining a first parameter of the input parameter corresponding to the target interface in the objective function of the interface;

[020引将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数; [020 lead to the request interface call request identifies the first parameter and the interface function as the target of the input parameters, the interface function call to the target;

[0209] 获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数; [0209] obtain an output parameter of the target interface returning to the calling function, the output parameter includes the request ID and the second parameter;

[0210] 基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0210] based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script.

[0211] 在一种实施例中,所述输出参数的数据类型为预设的第一数据类型; [0211] In one embodiment, the data type of the parameter to output a first predetermined type of data;

[0212] 处理器401执行所述根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数的操作之后,还包括执行W下操作: After the [0212] processor 401 executes the call according to the embodiment and the interface parameters, determining the operating parameter of the first input parameter corresponding to the target interface in the target interface function, W further comprising performing the following:

[0213] 将所述第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型; [0213] The first parameter format conversion, data type of the first parameter after conversion to the preset second data type;

[0214] 处理器401执行所述获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数的操作之后,还包括执行W下操作: [0214] The processor 401 executes the obtaining output parameter returning to the calling function interfaces of the target, said output parameter comprises the request operation identifier and the second parameter, the method further comprising performing the operation W:

[0215] 将所述第二参数进行格式转换,转换后的第二参数的数据类型为预设的第=数据类型。 [0215] The second parameter format conversion, data type of the second parameter after conversion to the preset type of data =.

[0216] 在一种实施例中,处理器401执行所述根据所述调用方式和所述接口参数,确定所述目标接口函数的输入参数中的第一参数的操作,包括执行W下操作: [0216] In one embodiment, the processor 401 executes the call according to the embodiment and the interface parameters, determining a first operating parameter of the target interface function input parameters, comprising performing the operation W:

[0217]若所述调用方式为同步调用,将所述接口参数确定为所述目标接口函数的输入参数中的第一参数; [0217] If the call mode is a synchronous call, the interface parameters determined as the first parameter of the input parameter in the objective function interfaces;

[0218]若所述调用方式为异步调用,将所述接口参数中除预设参数外的其它参数确定为所述目标接口函数的输入参数中的第一参数,所述预设参数用于标识回调函数。 [0218] If the call mode is an asynchronous call, to determine the interface parameters preset parameters other parameters except for the first parameter of the object parameter input interface functions in the preset parameters for identifying Callback.

[0219]在一种实施例中,处理器401执行所述基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本,包括执行W下操作: [0219] In one embodiment, the processor 401 performs, based on the second parameter, the request corresponding to the identifier of the interface invocation request call returns to the client-side script, comprising performing the operation W:

[0220] 若所述调用方式为同步调用,将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本; [0220] If the call mode is a synchronous call, return the script to the client as a result of calling the second parameter of the call request corresponding to the request identifies an interface;

[0221] 若所述调用方式为异步调用,确定所述请求标识对应的目标回调函数,并将所述第二参数作为所述目标回调函数的输入参数,运行所述目标回调函数得到输出结果,进而将所述输出结果作为所述接口调用请求的调用结果返回给客户端脚本。 [0221] If the call mode is an asynchronous call, determining a corresponding target request identifies the callback function, and the second parameter as an input parameter of the object callback, the callback function operation to obtain the target output, Further the output result back to the client script as a result of the call interface call request.

[0222]在一种实施例中,处理器401执行所述根据所述接口标识,确定所述目标接口的调用方式的操作之后,还包括执行W下操作: After [0222] In one embodiment, the processor 401 performs an interface according to the identifier of the call to determine the operating mode of the target interface, further comprising performing the operation W:

[0223]若所述调用方式为异步调用,将回调信息保存至回调数据库中,所述回调信息包括所述请求标识和所述预设参数所标识的回调函数; Save [0223] If the call mode is an asynchronous call to the callback information database callback, the callback request includes said identifying information and said preset parameters identified by a callback function;

[0224] 其中,处理器401执行所述确定所述请求标识对应的目标回调函数的操作,包括执行W下操作: [0224] wherein, the processor 401 performs the operation of determining a target identifier corresponding to the callback request includes an operation performed under the W:

[0225]若所述调用方式为异步调用,根据所述请求标识从所述回调数据库中查询所述请求标识对应的回调信息; [0225] If the call mode is an asynchronous call, the callback request corresponding to the identification information according to the request identifies callback query from the database;

[0226]将所述回调信息指定的回调函数确定为目标回调函数。 [0226] Specifies the callback function callback information is determined as the target callback function.

[0227]在一种实施例中,处理器401执行所述将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本的操作之后,还包括执行W下操作: After [0227] In one embodiment, the processor 401 executes the second parameter as a result of the call request to invoke the requested interface identifier corresponding to the returning operation to the client-side script, further comprising performing W the following:

[0228]删除所述回调数据库中所述请求标识对应的回调信息。 [0228] Remove the callback request a callback information of the database corresponding to the identifier.

[0229]在一种实施例中,处理器401执行根据所述接口标识,确定所述目标接口的调用方式的操作,包括执行W下操作: [0229] In one embodiment, the processor 401 performs an interface according to the identifier, the determining operation is called a target interface, comprising performing the operation W:

[0230]根据所述接口标识,从预设的接口数据库中查询所述接口标识对应的接口信息, 所述接口信息包括接口标识和调用方式; [0230] The said interface identifier, interface identifier of the interface information corresponding to the query from the default database interfaces, the interface information includes an interface identifier and a call mode;

[0231]将所述接口数据库中该接口标识对应的调用方式确定为所述目标接口的调用方式。 [0231] The determination of the target invocation interface in the interface to the database to identify the corresponding interface is called.

[0232]在本发明实施例描述的技术方案中,接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一;根据所述接口标识,确定目标接口的调用方式;根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数;将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数;获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数;基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 [0232] In the technical solutions described in the present embodiment of the invention, the invocation request reception interface, the interface call request carries the destination interface and the corresponding interface identifier with a client-side script interface parameters need to call the target interface is a browser one extended interface provided; accordance with the interface identifier, determining a target invocation interface; according to the call mode and the interface parameters, determining a first parameter of the input parameter corresponding to the target interface in the objective function of the interface; the interface call request identifies the request as an input parameter and the first parameter of the objective function of the interface, the interface function call to the target; output parameter obtaining the target interface returning to the calling function, the output parameter comprises the request identifies the second parameter; based on the second parameter, the call request corresponding to the identification result of the call to the interface request is returned to the client script. 采用本发明实施例,通过规范化接口函数的设计和接口调用,浏览器可W采用统一的接口调用方法来实现客户端脚本对任一扩展接口的调用。 Embodiment of the present invention, through the design and standardization of interface calls the interface functions, browser W unified interface calls methods to achieve client script calls for any extended interface. 从而,开发人员开发扩展接口时,只需开发该扩展接口对应的接口函数,提高开发效率。 Whereby, when the expansion interface developers, the ability to develop the expansion interface corresponding to the interface function, to improve development efficiency.

[0233] 在本说明书的描述中,参考术语"一个实施例"、"一些实施例"、"示例"、"具体示例"、或"一些示例"等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。 [0233] In the description of the present specification, reference to the term "one embodiment," "some embodiments", "an example", "a specific example", or "some examples" means that a description of the exemplary embodiment or embodiments described a particular feature, structure, material, or characteristic is included in at least one embodiment of the present invention, embodiments or examples. 在本说明书中,对上述术语的示意性表述不一定是必须针对相同的实施例或示例。 In the present specification, a schematic representation of the above terms is not always necessary to the same embodiment or example is for. 而且,描述的具体特征、结构、材料或者特点可W在任一个或多个实施例或示例中W合适的方式结合。 Furthermore, the particular features, structures, materials, or characteristics may be combined W embodiments or examples of W in any suitable manner one or more. 此外,在不相互矛盾的情况下,本领域的技术人员可W将本说明书中描述的不同实施例或示例W及不同实施例或示例的特征进行结合和组合。 Further, in a case where not mutually inconsistent, those skilled in the art can be different or W and W exemplary embodiment or exemplary embodiments various features of the embodiments described in this specification and the binding composition.

[0234] 本领域的技术人员可W将本说明书中描述的不同实施例W及不同实施例的特征进行结合和组合。 [0234] One skilled in the art may be W W different embodiments described in this specification and features of different embodiments be combined and combinations thereof. 本发明所有实施例中的模块或单元,可W通过通用集成电路,例如CPU(CentralProcessingUnit,中央处理器),或通过ASIC(ApplicationSpecific IntegratedCir州it,专用集成电路)来实现。 Examples modules or units in all embodiments of the present invention, a universal integrated circuit W through, for example, CPU (CentralProcessingUnit, central processing unit), or by ASIC (ApplicationSpecific IntegratedCir IT states, application specific integrated circuit) is achieved.

[0235] 本发明所有实施例方法中的步骤可W根据实际需要进行顺序调整、合并和删减; 本发明所有实施例装置中的模块或单元可W根据实际需要进行合并、划分和删减。 [0235] All steps of the method embodiments of the present invention W may be adjusted according to actual needs sequence, deletion and merger; all embodiments of the apparatus of the present invention W modules or units may be combined according to actual needs, division and deletion.

[0236] 流程图中或在此W其他方式描述的任何过程或方法描述可W被理解为,表示包括一个或更多个用于实现特定逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明的优选实施方式的范围包括另外的实现,其中可W不按所示出或讨论的顺序,包括根据所设及的功能按基本同时的方式或按相反的顺序,来执行功能,该应被本发明的实施例所属技术领域的技术人员所理解。 [0236] In the flowchart process or method or any other embodiment herein described W W description may be understood as representing modules comprises one or more steps for implementing specific logical functions or processes executable instructions , fragment or portion, and the scope of the preferred embodiment of the present invention includes other implementations, where W may be shown or discussed in order not to press, and comprising the functions provided by the substantially simultaneous manner or in reverse order, to perform functions, which should be understood that embodiments of the present invention. Those skilled in the art.

[0237] 在流程图中表示或在此W其他方式描述的逻辑和/或步骤,例如,可W被认为是用于实现逻辑功能的可执行指令的定序列表,可W具体实现在任何计算机可读介质中,W 供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可W从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合该些指令执行系统、装置或设备而使用。 Logic and / or steps [0237] W represents or otherwise described herein in the flowchart, for example, W can be understood as a sequence listing of executable instructions for implementing logical functions, can be embodied in any computer-W readable medium, W instruction execution system, apparatus, or device (e.g., computer-based system, including a processor or other system W from the instruction execution system, apparatus, or device and execute the instructions fetch system) used, or a combination the plurality of instruction execution system, apparatus, or device used. 就本说明书而言,"计算机可读介质"可W是任何可W包含、存储、通信、传播或传输程序W供指令执行系统、装置或设备或结合该些指令执行系统、装置或设备而使用的装置。 For purposes of this specification, a "computer-readable medium" can be any W W contain, store, communicate, propagate, or transport the program for the W instruction execution system, apparatus, or device, or in conjunction with the plurality of instruction execution system, apparatus, or device used s installation. 计算机可读介质的更具体的示例(非穷尽性列表)包括W下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器巧PROM或闪速存储器),光纤装置,W及便携式光盘只读存储器(CDR0M)。 More specific examples (a non exhaustive list) of the computer-readable medium includes a lower W is: an electrical connection (electronic device) having one or more wires, a portable computer diskette cartridge (magnetic device), a random access memory (RAM) , read only memory (ROM), erasable read-only memory edit Qiao PROM or flash memory), an optical fiber apparatus, W, and a portable compact disc read-only memory (CDR0M). 另外,计算机可读介质甚至可W是可在其上打印所述程序的纸或其他合适的介质,因为可W例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时W其他合适方式进行处理来W电子方式获得所述程序,然后将其存储在计算机存储器中。 Further, the computer-readable medium may even be paper W or other suitable medium upon which the program is printed, as, for example, W may be paper or other medium by optical scanning, and then edited, if necessary, interpreted, or W other suitable means for electronically processing to obtain the W program, and then stored in a computer memory.

[023引本技术领域的普通技术人员可W理解实现上述实施例方法携带的全部或部分步骤是可W通过程序来指令相关的硬件完成,所述的程序可W存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。 [023 lead one of ordinary skilled in the art can understand that the above-described embodiments W Example that all or part of the steps may be W instructing relevant hardware via a program, the program may be stored in W stored in a computer-readable medium, when the program is executed, the method comprising the steps of the one embodiment or a combination thereof.

[0239] 此外,在本发明各个实施例中的各功能单元可W集成在一个处理模块中,也可W 是各个单元单独物理存在,也可W两个或两个W上单元集成在一个模块中。 [0239] Further, in various embodiments of the present invention, the functional units may be integrated in a W processing module may also be physically separate units W is present, W can also be two or more units are integrated on a module W in. 上述集成的模块既可W采用硬件的形式实现,也可W采用软件功能模块的形式实现。 The integrated module can take the form of a hardware implementation of W, W may also be employed in the form of software functional module implemented. 所述集成的模块如果W软件功能模块的形式实现并作为独立的产品销售或使用时,也可W存储在一个计算机可读取存储介质中。 If the module is integrated in the form of W software function module implemented as an independent product sold or used, W may also be stored in readable storage medium in a computer.

[0240] 上述提到的存储介质可W是只读存储器,磁盘或光盘等。 [0240] The storage medium may be W is a read-only memory, magnetic or optical disk. 尽管上面已经示出和描述了本发明的实施例,可W理解的是,上述实施例是示例性的,不能理解为对本发明的限审IJ,本领域的普通技术人员在本发明的范围内可W对上述实施例进行变化、修改、替换和变型。 Although the above has been illustrated and described embodiments of the present invention, W is understood that the above embodiments are exemplary and are not to be understood as limiting Unexamined IJ of the present invention, within the scope of the present invention to those of ordinary skill in the art W may be variations of the above embodiments, modifications, alternatives, and modifications.

[0241]W上所揭露的仅为本发明的较佳实施例而已,当然不能W此来限定本发明之权利范围,本领域普通技术人员可W理解实现上述实施例的全部或部分流程,并依本发明权利要求所作的等同变化,仍属于发明所涵盖的范围。 The [0241] W descriptions are merely preferred embodiments of the present invention, it, of course, not to limit the scope of this W of the present invention, those of ordinary skill in the art can understand that the above embodiments W all or part of the process, and equivalent changes made under this invention as claimed in claim still encompassed within the scope of the present invention.

Claims (10)

  1. 1. 一种接口调用方法,其特征在于,包括: 接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一; 根据所述接口标识,确定所述目标接口的调用方式; 根据所述调用方式和所述接口参数,确定所述接口标识对应的目标接口函数的输入参数中的第一参数; 将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数, 调用所述目标接口函数; 获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数; 基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 CLAIMS 1. A method of interface calls, which is characterized in that, comprising: an interface receiving a call request, the interface call request carries a calling client script needs target interface identifier and an interface corresponding to the interface parameter, and the target interface is a browser one extended interface provided; accordance with the interface identifier, determining a target invocation interface; interface parameters according to the embodiment and the call, determining a first input parameter of the corresponding target interface identifier of the interface function parameter; the interface call request identifies the request and the first parameter as an input parameter of the interface function of the target, the target interface function call; output parameter obtaining the target interface returning to the calling function, the output parameter includes a second parameter and the request identification; based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script.
  2. 2. 如权利要求1所述的方法,其特征在于,所述输出参数的数据类型为预设的第一数据类型; 所述根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数之后,所述方法还包括: 将所述第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型; 所述获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数之后,所述方法还包括: 将所述第二参数进行格式转换,转换后的第二参数的数据类型为预设的第三数据类型。 2. The method according to claim 1, wherein said output data type parameter is a first predetermined data type; according to the embodiment of the interface parameters and said call, determining the target corresponding to the interface after the first parameter input parameter function of the target interface, the method further comprising: the first parameter format conversion, data type of the first parameter after conversion into a second predetermined data type; the after obtaining the output parameter returns the target interface function call, comprising, after said output parameter and a second parameter identifying said request, said method further comprising: the second format conversion parameter, the second parameter after conversion the default data type is the third type of data.
  3. 3. 如权利要求1或2所述的方法,其特征在于,所述根据所述调用方式和所述接口参数,确定所述目标接口对应的目标接口函数的输入参数中的第一参数包括: 若所述调用方式为同步调用,将所述接口参数确定为所述目标接口函数的输入参数中的第一参数; 若所述调用方式为异步调用,将所述接口参数中除预设参数外的其它参数确定为所述目标接口函数的输入参数中的第一参数,所述预设参数用于标识回调函数。 3. The method of claim 1 or claim 2, wherein said call according to the embodiment and the interface parameters, determining a first parameter of the input parameter corresponding target destination interface interface functions include: If the invocation mode is a synchronous call, the interface parameters of the first parameter is determined as input parameters of the target function of the interface; if the call mode is an asynchronous call, the interface parameters, in addition to the parameters preset other parameters determined as the first input parameter to the target parameter function in the interface, the preset parameter identifies the callback function.
  4. 4. 如权利要求1或2所述的方法,其特征在于,所述基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本包括: 若所述调用方式为同步调用,将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本; 若所述调用方式为异步调用,确定所述请求标识对应的目标回调函数,并将所述第二参数作为所述目标回调函数的输入参数,运行所述目标回调函数得到输出结果,进而将所述输出结果作为所述接口调用请求的调用结果返回给所述客户端脚本。 4. The method according to claim 1, characterized in that, based on the second parameter, the result of the call request requesting call corresponding to the identifier of the interface returns to the client script comprises: if the said call for the synchronous call, the second call request parameter as a result of the interface call request corresponding to the identifier is returned to the client script; if the call mode is an asynchronous call, the request corresponding to the identifier is determined objective callback function, and the second parameter as the target input parameters callback, the callback function operation to obtain the target output, and then outputs the result as the result of the call request for calling the interface returns to the client script.
  5. 5. 如权利要求4所述的方法,其特征在于,所述根据所述接口标识,确定所述目标接口的调用方式之后,所述方法还包括: 若所述调用方式为异步调用,将回调信息保存至回调数据库中,所述回调信息包括所述请求标识和所述预设参数所标识的回调函数; 所述确定所述请求标识对应的目标回调函数,包括: 若所述调用方式为异步调用,根据所述请求标识从所述回调数据库中查询所述请求标识对应的回调信息; 将所述回调信息指定的回调函数确定为目标回调函数。 5. After the method as claimed in claim 4, wherein said interface identifier according to the determining of the target invocation interface, the method further comprising: if the asynchronous call is called by the callback information stored in the database to the callback, the callback request includes said identifying information and said preset parameters identified by a callback function; determining the request identifies the corresponding target callback function, comprising: an asynchronous mode if the calling call, according to the request identification information identifying the callback query corresponding to the request from the callback database; callback information specifying the callback function is determined as the target callback function.
  6. 6. 如权利要求5所述的方法,其特征在于,所述将所述第二参数作为所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本之后,所述方法还包括: 删除所述回调数据库中所述请求标识对应的回调信息。 6. The method according to claim 5, wherein said second parameter as the result of the call after the call request corresponding to the request identifying the interface returns to the client-side script, the method further comprises : remove the callback information identifying the callback request corresponding to the database.
  7. 7. 如权利要求1或2所述的方法,其特征在于,所述根据所述接口标识,确定所述目标接口的调用方式包括: 根据所述接口标识,从预设的接口数据库中查询所述接口标识对应的接口信息,所述接口信息包括接口标识和调用方式; 将所述接口数据库中该接口标识对应的调用方式确定为所述目标接口的调用方式。 7. The method of claim 1 or claim 2, wherein said interface identifier according to said determining the target invocation interface comprising: an interface according to the identifier, the query interface to the database from the default said interface information corresponding to an interface identifier, interface identifier comprises the interface information and invoking manner; the interface to the database is called by a corresponding interface identifier is determined as the target invocation interface.
  8. 8. -种接口调用装置,其特征在于,包括: 接收模块,用于接收接口调用请求,所述接口调用请求携带有客户端脚本需要调用的目标接口对应的接口标识和接口参数,所述目标接口为浏览器所提供的扩展接口之一; 方式确定模块,用于根据所述接口标识,确定所述目标接口的调用方式; 参数确定模块,用于根据所述调用方式和所述接口参数,确定所述接口标识对应的目标接口函数的输入参数中的第一参数; 调用模块,用于将所述接口调用请求的请求标识和所述第一参数作为所述目标接口函数的输入参数,调用所述目标接口函数; 获取模块,用于获取调用所述目标接口函数后返回的输出参数,所述输出参数包括所述请求标识和第二参数; 返回模块,用于基于所述第二参数,将所述请求标识对应的接口调用请求的调用结果返回给所述客户端脚本。 8. - kind of interface calls apparatus comprising: a receiving module, configured to receive a request for calling the interface, the interface call request carries the destination interface and the corresponding interface identifier interface parameters need to call the client-side script, the target an extension of the interface provided by the browser interface; a mode determining module, according to the interface identification, to determine the target invocation interface; parameter determination module, according to the mode and parameters of the call interfaces, determining a first parameter of the input parameter to the target interface function corresponding to the interface identifier; call module configured to interface call request identifies the request and the first parameter as an input parameter of the target interface function calls the target interface function; obtaining module, configured to obtain the output parameters of the target interface returning to the calling function, the output parameter includes the request ID and the second parameter; returning module, based on the second parameter, the result of the call request to the call request corresponding to the identifier of the interface returns to the client script.
  9. 9. 如权利要求8所述的装置,其特征在于,所述输出参数的数据类型为预设的第一数据类型,所述装置还包括: 第一转换模块,用于将所述第一参数进行格式转换,转换后的第一参数的数据类型为预设的第二数据类型; 第二转换模块,用于将所述第二参数进行格式转换,转换后的第二参数的数据类型为预设的第三数据类型。 9. The apparatus according to claim 8, wherein said output parameter data type to a first predetermined type of data, said apparatus further comprising: a first conversion module for converting the first parameter format conversion, data type of the first parameter after conversion to a second predetermined type of data; a second conversion module, the second parameter is used to perform format conversion, data type of the second parameter after conversion to pre the third set of data types.
  10. 10. -种终端,其特征在于,包括如权利要求8-14任一项所述的接口调用装置。 10. - type of terminal, wherein the interface call device according to any one of claims 8-14 comprising.
CN 201510289070 2015-05-29 2015-05-29 Interface calling method, apparatus, and terminal CN104866383A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201510289070 CN104866383A (en) 2015-05-29 2015-05-29 Interface calling method, apparatus, and terminal

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN 201510289070 CN104866383A (en) 2015-05-29 2015-05-29 Interface calling method, apparatus, and terminal
PCT/CN2016/083359 WO2016192556A1 (en) 2015-05-29 2016-05-25 Interface invoking method, device and terminal

Publications (1)

Publication Number Publication Date
CN104866383A true true CN104866383A (en) 2015-08-26

Family

ID=53912231

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201510289070 CN104866383A (en) 2015-05-29 2015-05-29 Interface calling method, apparatus, and terminal

Country Status (2)

Country Link
CN (1) CN104866383A (en)
WO (1) WO2016192556A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080016498A1 (en) * 2001-03-23 2008-01-17 S2 Technologies, Inc. System and method for generating data sets for testing embedded systems
US20130013751A1 (en) * 2009-05-11 2013-01-10 Accenture Global Services Limited Enhanced network adapter framework
CN103226474A (en) * 2013-05-10 2013-07-31 北京奇虎科技有限公司 Method, device and system for interaction between webpage script and browser program
CN103309728A (en) * 2012-03-12 2013-09-18 腾讯科技(深圳)有限公司 Asynchronous request processing method and equipment
CN104281455A (en) * 2014-10-11 2015-01-14 北京金山安全软件有限公司 Method, device and terminal for invoking interfaces

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103177040A (en) * 2011-12-26 2013-06-26 腾讯科技(深圳)有限公司 Method and device for calling functions of webpage application
CN104866383A (en) * 2015-05-29 2015-08-26 北京金山安全软件有限公司 Interface calling method, apparatus, and terminal

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080016498A1 (en) * 2001-03-23 2008-01-17 S2 Technologies, Inc. System and method for generating data sets for testing embedded systems
US20130013751A1 (en) * 2009-05-11 2013-01-10 Accenture Global Services Limited Enhanced network adapter framework
CN103309728A (en) * 2012-03-12 2013-09-18 腾讯科技(深圳)有限公司 Asynchronous request processing method and equipment
CN103226474A (en) * 2013-05-10 2013-07-31 北京奇虎科技有限公司 Method, device and system for interaction between webpage script and browser program
CN104281455A (en) * 2014-10-11 2015-01-14 北京金山安全软件有限公司 Method, device and terminal for invoking interfaces

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016192556A1 (en) * 2015-05-29 2016-12-08 北京金山安全软件有限公司 Interface invoking method, device and terminal

Also Published As

Publication number Publication date Type
WO2016192556A1 (en) 2016-12-08 application

Similar Documents

Publication Publication Date Title
US20040205697A1 (en) Transferring data along with code for program overlays
US20060020692A1 (en) System and method for locating web services
US20140215446A1 (en) Automated Porting of Application to Mobile Infrastructures
US6922735B2 (en) Management of co-processor information by integrating non-program information with program information
CN101571809A (en) Implementation method of plug-in registration and device thereof
US20090199213A1 (en) Automatic Connections Between Application Components
JP2003308205A (en) Method for temporarily halting program
US20130174154A1 (en) Java Virtual Machine Embedded in a Native Mobile Application
CN102413022A (en) Application debugging method and system
CN101697139A (en) Method, device and registry for remote procedure call
CN102567516A (en) Script loading method and device
US7730492B1 (en) Method and system for running multiple virtual machines in a single process
CN102323887A (en) Browser engine-based method for dynamically loading Widget and mobile terminal
CN101931603A (en) Method for realizing remote call on hand-held intelligent terminal
CN101667139A (en) Service program invocation method based on aggregate type object, device and system therefor
CN101303650A (en) Method and system for extending function of software platform
JP2005228183A (en) Program execution method and computer system for executing the program
US20130219415A1 (en) Method for executing hybrid web application and apparatus therefor
CN102831043A (en) Monitoring method and device for application program
CN101576989A (en) Method for realizing payment in mobile terminal and mobile device
US20110154297A1 (en) Dynamic instrumentation
CN103106102A (en) Running method of Web application program and mobile terminal
CN101364236A (en) Data processing apparatus and processing method of WEB page
JP2003141070A (en) Device
US20140039885A1 (en) Methods and apparatus for voice-enabling a web application

Legal Events

Date Code Title Description
C06 Publication
EXSB Decision made by sipo to initiate substantive examination