This shows you the differences between two versions of the page.
en:public:developer:template_system:tags:api:add_lead [2013/01/14 16:01] admin [RESTFul API] |
en:public:developer:template_system:tags:api:add_lead [2013/03/30 18:08] (current) svanderclock [CfgPages configuration] |
||
---|---|---|---|
Line 2: | Line 2: | ||
Use this function to add a lead in the database. This function must be called only from | Use this function to add a lead in the database. This function must be called only from | ||
- | [[en:public:developer:template_system:cfgpages]]. The Lead will be also connected to the current web | + | [[en:public:developer:template_system:cfgpages]]. The Lead will be connected to the current web |
- | user as the Buyer. The ID of the referrer (if any) of the lead will be extracted from the cookie | + | user (as the Buyer). The ID of the referrer (if any) of the lead will be extracted from the cookie |
[[en:public:developer:template_system:reserved_parameters:ak__source]] | [[en:public:developer:template_system:reserved_parameters:ak__source]] | ||
==== CfgPages configuration ==== | ==== CfgPages configuration ==== | ||
<code xml> | <code xml> | ||
- | <page name="My_Add_lead_Api_Function"> | + | <page name="add_lead"> |
- | <cfg> | + | <cfg> |
- | <userrights> | + | <userrights> |
- | <userright name="ALLUSER"/> | + | <userright name="ALLUSER"/> |
- | </userrights> | + | </userrights> |
- | <frames> | + | <frames> |
- | <frame name="mainframe" processname="Add_lead" preload="1"/> | + | <frame name="content" processname="add_lead"/> |
- | </frames> | + | </frames> |
- | </cfg> | + | <maintemplate>maintemplates\maintemplate_empty.html</maintemplate> |
- | </page> | + | <content_type><#content_type></content_type> |
+ | </cfg> | ||
+ | </page> | ||
</code> | </code> | ||
- | ==== RESTFUL API ==== | + | ==== Parameters ==== |
- | The ArKadia API currently supports a [[http://en.wikipedia.org/wiki/REST|RESTful]] interface, that essentially | + | Parameters are taken from tag (default) or from HTTP GET/Post |
- | means you can send an HTTP GET or POST to call exposed methods, and you'll get back an XML document | + | |
- | in return. | + | |
- | + | ||
- | When you call this function, you'll get a response in XML that looks like this: | + | |
- | + | ||
- | <code xml> | + | |
- | <rsp stat="ok" version="1.0"> | + | |
- | [Data in XML format - see individual method docs] | + | |
- | </rsp> | + | |
- | </code> | + | |
- | + | ||
- | If there's an error, you'll get a response with an error message about the problem. | + | |
- | + | ||
- | <code xml> | + | |
- | <rsp stat="fail"> | + | |
- | <error msg="Error Message" /> | + | |
- | <rsp> | + | |
- | </code> | + | |
- | + | ||
- | ==== HTTP Get/Post Parameters ==== | + | |
^ Name ^ Mandatory ^ Default ^ Description ^ | ^ Name ^ Mandatory ^ Default ^ Description ^ | ||
Line 57: | Line 39: | ||
==== Example ==== | ==== Example ==== | ||
- | <code> | + | Ajax example on jQuery |
+ | |||
+ | <code javascript> | ||
+ | |||
+ | $.ajax({ | ||
+ | cache: false, | ||
+ | type: "GET", | ||
+ | data: { | ||
+ | Property.ID: 'CA-T1', | ||
+ | Lead.type: 2 | ||
+ | }, | ||
+ | url: '<#url id="/api/add_lead/">', | ||
+ | dataType: "xml", | ||
+ | success: callbackfunction_on_success, | ||
+ | error: function (jqXHR, textStatus, errorThrown) {} | ||
+ | }); | ||
+ | function callbackfunction_on_success (response) { | ||
+ | var $root = $('rsp',response); | ||
+ | if ($root.attr('stat') == 'ok'){ | ||
+ | var leadid = $root.find('id').Html(); | ||
+ | } | ||
+ | } | ||
</code> | </code> |