Connecting sites via API

You can set up integration with a landing page that is hosted by a third-party service. To do this, you need to create a script handler, which will collect orders from the landing page. The script will send requests to the system via the API to add orders in the project.

API (Application Programming Interface) is a description of the ways in which one computer program can interact with another program. In other words, as a part of our service, this is a method or tool which allows you to configure the integration (connection) between our system and other services.

To send orders to a project, you can use any API, both advanced and for webmasters.


API for webmasters

Advantages:

- API for webmasters is available at all basic tariffs (except Cold Sales);

- this method is suitable for webmasters to connect their own landing pages to your project.

Disadvantages:

- When working with several webmasters, you need to revise the site and a more complex version of the script to assign orders to webmasters;

- Replacing the API key in the webmasters' personal account is inconvenient, it is problematic to connect new webmasters to this landing page.

To connect, you need to follow these steps:

  1. Follow the link of your affiliate program in LeadVertex and register as a webmaster

8487ead780.png

  1. In the webmaster's account, enter the project you need and open “API” tab

ff0b05ab23.png

  1. Go to "Import Orders" #addOrder method and use the url to send requests and other available options for creating the script. Copy a good ID from the warehouse in your project. *
  2. In the entrepreneur’s account (admin’s), enter the project you need. On the top control panel click "Webmasters" tab - Personal settings for webmasters. Select your registered webmaster account and open the card with personal settings by clicking on pencil sign

b451a5966b.png

In personal settings, allow yourself, as a webmaster, to import orders via API.

* At your hosting end, you have to make some settings: to create a script that will send requests to CRM to add an order. Then set up the order form on the website to transfer requests for this script.

Unfortunately, it is impossible to prepare a universal script that you could download and put on your hosting (for this you can use not API, but embedding the code of the form generated in the project on the site). But we made an example of the script for a very simple form on the landing page.

Here is an example of a script for transferring orders with a name and phone number of a customer and products that the customer has ordered:


    <!--?php
$project = "Name of the project";
$webmasterID = "webmaster’s id in the project";
$apiKey = "API-key for webmaster";
function sendOrder($orderData, $project, $apiKey, $webID)
{
    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL =-->
     "http://{$project}.leadvertex.ru/api/webmaster/addOrder.html?webmasterID={$webID}&token={$apiKey}",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            'Content-Type' => 'application/x-www-form-urlencoded'
        ],
        CURLOPT_POSTFIELDS => http_build_query($orderData)
    ]);
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}
$productList = [
    0 => [
        'goodID' => 15,
        'quantity' => 1,
        'price' => 500
    ]
];
$orderData = [
    'fio' => $_POST['name'],
    'phone' => $_POST['phone'],
    'goods' => $productList,
];
sendOrder($orderData, $project, $apiKey, $webmasterID);

Wherein, in the "index" file in the landing page code, for the "action" parameter of the form, you need to input the name of the script that you uploaded to the directory.


Advanced API

Advantages:

- Simple connection;

- Ability to easily connect a new webmaster;

- Many parameters for transferring data to the project;

- It is not difficult to adapt the setting for different projects.

Disadvantages:

- The Advanced API is not available on all tariffs.(Available on CRM+ and CRM PRO)

To connect, you need to follow these steps:

  1. Enter the project - Settings - Modules - API. Input your API key and save changes.
  2. At the same page open a special link for getting personal API documentation which contains the password for accessing the API (Token) and the name of the project.

d41ee48680.png

  1. At your hosting end, create a script to transfer orders to the project using the data from the personal API documentation. Configure the forms on the site so that the data is sent to this script. *

* Here is a simple example script for sending orders via API for administrators (advanced)

<?php
$project = "Name of the project";
$project = "Name of the project";
$apiKey = "API key for the project";
function sendOrder($orderData, $project, $apiKey)
{
    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => "http://{$project}.leadvertex.ru/api/admin/addOrder.html?token={$apiKey}",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            'Content-Type' => 'application/x-www-form-urlencoded'
        ],
        CURLOPT_POSTFIELDS => http_build_query($orderData)
    ]);
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}
$productList = [
    0 => [
        'goodID' => 15,
        'quantity' => 1,
        'price' => 500
    ]
];
$orderData = [
    'fio' => $_POST['name'],
    'phone' => $_POST['phone'],
    'goods' => $productList,
];
sendOrder($orderData, $project, $apiKey);


You can set up the integration on your own, or you can send a request to a tech support ticket for our specialist to set up an integration.

Call back application

We work from 8 am till 8 pm (moscow time) every day.
Please state convenient time for calling back at the working hours of our technical support service!