Пример партнерки:
<?php
define('API_TOKEN', ''); //Токен доступа к апи. Можно получить по адресу http://webmaster.leads.su/account/default
define('API_PLATFORM_ID', 1089179); //ID площадки подключеной к оферу
define('API_OFFER_ID', 671); //ID офера
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = API_OFFER_ID;
// Тестовая анкета
$fields['is_test'] = 1;
//Обязательные поля
$fields['firstname'] = '';
$fields['lastname'] = '';
$fields['middlename'] = '';
$fields['email'] = '';
$fields['mphone'] = '';
//Необязательные поля
$fields['overdue_loans'] = '';
$fields['birthplace'] = '';
$fields['passport_code'] = '';
$fields['passport_title'] = '';
$url = 'http://api.leads.su/webmaster/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
if ($response == null) {
echo "API answer is empty\n";
} else {
if ($httpCode == 200 && $response['status'] == 'success') {
echo "Success push\n";
var_dump($response['data']);
} else {
echo "Errors\n";
if (isset($response['error'])) {
var_dump($response['error']);
} elseif (isset($response['error_msg'])) {
var_dump($response['error_msg']);
}
}
}
А вот что у меня:
<?php
header("Content-Type: text/html; charset=utf-8");
error_reporting(E_ALL);
include ('./data/conect.php');
// разбираем переменные
$summa = $_POST['summa'];
$srok = $_POST['srok'];
$last_name = $_POST['last_name'];
$first_name = $_POST['first_name'];
$middle_name = $_POST['middle_name'];
$sex = $_POST['sex'];
$drd = $_POST['drd'];
$drm = $_POST['drm'];
$dry = $_POST['dry'];
$region = $_POST['region'];
$city = $_POST['city'];
$phone_number = $_POST['phone_number'];
$email = $_POST['email'];
$business_id = $_POST['business_id'];
$work_name = $_POST['work_name'];
$work_specialnost = $_POST['work_specialnost'];
$dohod_mes = $_POST['dohod_mes'];
$work_total_period_years = "";
$work_total_period_month = "";
$work_period_years = "";
$work_period_month = $_POST['stage_last'];
$work_contact_name = $_POST['work_contact_name'];
$work_phone_number = $_POST['work_phone_number'];
$passport_seriya = $_POST['passport_seriya'];
$passport_number = $_POST['passport_number'];
$passport_podrazdel = $_POST['passport_podrazdel'];
$passport_kemv = $_POST['passport_kemv'];
$passport_day = $_POST['passport_day'];
$passport_month = $_POST['passport_month'];
$passport_year = $_POST['passport_year'];
$passport_birthplace = $_POST['passport_birthplace'];
$register_place_name = "";
$register_street_name = "";
$register_home_number = "";
$register_home_building = "";
$register_home_apartment = "";
$region_reg = $_POST['region_reg'];
$city_reg = $_POST['city_reg'];
$region_fact = $_POST['region_fact'];
$city_fact = $_POST['city_fact'];
$stage_last = $_POST['stage_last'];
$regions = array(
3160 => "Алтайский край",
3223 => "Амурская область",
3251 => "Архангельская область",
3282 => "Астраханская область",
3296 => "Республика Башкортостан",
3352 => "Белгородская область",
3371 => "Брянская область",
3407 => "Республика Бурятия",
3437 => "Владимирская область",
3468 => "Волгоградская область",
3503 => "Вологодская область",
3529 => "Воронежская область",
3563 => "Нижегородская область",
3630 => "Республика Дагестан",
3673 => "Еврейская АО",
3675 => "Ивановская область",
3703 => "Иркутская область",
3751 => "Республика Кабардино-Балкария",
3761 => "Калининградская область",
3784 => "Тверская область",
3827 => "Республика Калмыкия",
3841 => "Калужская область",
3872 => "Камчатский край",
3892 => "Республика Карелия",
3921 => "Кемеровская область",
3952 => "Кировская область",
3994 => "Республика Коми",
4026 => "Костромская область",
4052 => "Краснодарский край",
4105 => "Красноярский край",
4176 => "Курганская область",
4198 => "Курская область",
4227 => "Липецкая область",
4243 => "Магаданская область",
4270 => "Республика Марий Эл",
4287 => "Республика Мордовия",
4312 => "Московская область",
4481 => "Мурманская область",
4503 => "Новгородская область",
4528 => "Новосибирская область",
4561 => "Омская область",
4593 => "Оренбургская область",
4633 => "Орловская область",
4657 => "Пензенская область",
4689 => "Пермский край",
4734 => "Приморский край",
4773 => "Псковская область",
4800 => "Ростовская область",
4861 => "Рязанская область",
4891 => "Самарская область",
4925 => "Ленинградская область",
4969 => "Саратовская область",
5011 => "Республика Саха (Якутия)",
5052 => "Сахалинская область",
5080 => "Свердловская область",
5151 => "Республика Северная Осетия — Алания",
5161 => "Смоленская область",
5191 => "Ставропольский край",
5225 => "Тамбовская область",
5246 => "Республика Татарстан",
5291 => "Томская область",
5312 => "Республика Тыва (Тува)",
5326 => "Тульская область",
5356 => "Тюменская область",
5404 => "Республика Удмуртия",
5432 => "Ульяновская область",
5473 => "Хабаровский край",
5507 => "Челябинская область",
5543 => "Республика Чечня",
5555 => "Забайкальский край",
5600 => "Республика Чувашия",
5625 => "Ярославская область",
1998532 => "Республика Адыгея",
2316497 => "Республика Хакасия",
2415585 => "Чукотский АО",
2499002 => "Ханты-Мансийский АО — Югра",
5019394 => "Ямало-Ненецкий АО",
15789406 => "Алтайский край",
15789407 => "Республика Ингушетия",
15789408 => "Республика Карачаево-Черкесия",
15789409 => "Москва",
15789410 => "Санкт-Петербург",
15789411 => "Ненецкий АО");
// заносим данные в базу
$add_item = mysql_query("INSERT INTO credits(
`summa`,`srok`,`last_name`,`first_name`,`middle_name`,
`sex`,`drd`,`drm`,`dry`,`region`,`city`,`phone_number`,`email`,
`work_type`,`work_organization`,`work_position`,
`work_money_pm`,`work_stage`,`work_stage_t`,`work_stage_now`,`work_stage_t_now`,`work_contact 112;`,`work_phone`,
`passp_serial`,`passp_numb`,`passp_code`,`passp_place`,
`passp_city`,`passp_street`,`passp_home`,`passp_block`,`passp_apartament`,
`status`,`passp_date`,`passp_burthplace`)
VALUES (
'$summa','$srok','$last_name','$first_name','$middle_name',
'$sex','$drd','$drm','$dry','$region','$city','$phone_number','$email',
'$business_id','$work_name','$work_specialnost',
'$dohod_mes','$work_total_period_years','$work_total_period_month','$work_period_years','$work_period_month','$work_contact_name','$work_phone_number',
'$passport_seriya','$passport_number','$passport_podrazdel','$passport_kemv',
'$register_place_name','$register_street_name','$register_home_number','$register_home_building','$register_home_apartment',
'0','$passport_day-$passport_month-$passport_year','$passport_birthplace')");
$birth_leadssu = $drd."-".$drm."-".$dry;
if ($sex == "1") $sex_leads = "1"; else $sex_leads = "0";
$mob1=substr($phone_number, 0, 3); $mob2=substr($phone_number, 3, 3); $mob3=substr($phone_number, 6, 2); $mob4=substr($phone_number, 8, 2);
$phone = "+7 ".$mob1." ".$mob2."-".$mob3."-".$mob4;
function sendData($url, $post) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
/////////////////////////
if($srok < 1) {
switch($srok) {
case "0.1": $srok_leads = 7; break;
case "0.2": $srok_leads = 14; break;
case "0.3": $srok_leads = 21; break;
case "0.4": $srok_leads = 28; break;
}
} else {
if($srok >= 12) {
switch($srok) {
case "12": $srok_leads = 365; break;
case "24": $srok_leads = 730; break;
case "36": $srok_leads = 1095; break;
case "48": $srok_leads = 1460; break;
case "60": $srok_leads = 1825; break;
}
} else {
$srok_leads = $srok * 30;
}
}
define('API_TOKEN', 'тут токен'); //Токен доступа к апи.
define('API_PLATFORM_ID', тут номер площадки); //ID площадки подключеной к оферу
/////////////////
preg_match("/([0-9]{3})([0-9]{3})/", $passport_podrazdel, $match);
$passport_key = $match[1]."-".$match[2];
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 485;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['middlename'] = $middle_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['mphone'] = $phone;
$fields['reg_region_name'] = $region_reg;
$fields['reg_city_name'] = $city_reg;
$fields['fact_region_name'] = $region_fact;
$fields['fact_city_name'] = $city_fact;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads;
$fields['gender'] = $sex_leads;
$fields['passport_code'] = $passport_seriya." ".$passport_number;
$fields['passport_date'] = $passport_year."-".$passport_month."-".$passport_day;
$fields['passport_title'] = $passport_kemv.", ".$passport_key;
$fields['birthplace'] = $passport_birthplace;
//Необязательные поля
$fields['overdue_loans'] = '';
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 517;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['middlename'] = $middle_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['mphone'] = "7".$phone_number;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads; // С большей вероятностью анкета будет принята если credit_days будет в диапазоне от 182 до 364
$fields['fact_region_name'] = $region_fact;
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 514;
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['middlename'] = $middle_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['mphone'] = "7".$phone_number;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads; // С большей вероятностью анкета будет принята если credit_days будет в диапазоне от 182 до 364
$fields['fact_region_name'] = $region_fact;
$fields['fact_city_name'] = $city_fact;
$fields['email'] = $email;
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 505;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['middlename'] = $middle_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['gender'] = $sex_leads;
$fields['mphone'] = "7".$phone_number;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads; // С большей вероятностью анкета будет принята если credit_days будет в диапазоне от 182 до 364
$fields['fact_region_name'] = $region_fact;
$fields['fact_city_name'] = $city_fact;
$fields['email'] = $email;
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 132;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['mphone'] = "7".$phone_number;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads; // С большей вероятностью анкета будет принята если credit_days будет в диапазоне от 182 до 364
$fields['fact_region_name'] = $region_fact;
$fields['email'] = $email;
$fields['overdue_loans'] = 'credit_closed_no_delay';
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 532;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['middlename'] = $middle_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['mphone'] = $phone;
$fields['gender'] = $sex_leads;
$fields['reg_region_name'] = $region_reg;
$fields['reg_city_name'] = $city_reg;
$fields['fact_region_name'] = $region_fact;
$fields['fact_city_name'] = $city_fact;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads;
$fields['passport_code'] = $passport_seriya.$passport_number;
$fields['passport_date'] = $passport_year."-".$passport_month."-".$passport_day;
$fields['birthplace'] = $passport_birthplace;
$fields['fact_street'] = 'не указано';
$fields['fact_house'] = '0';
$fields['reg_street'] = 'не указано';
$fields['reg_house'] = '0';
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 543;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['middlename'] = $middle_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['mphone'] = $phone;
$fields['gender'] = $sex_leads;
$fields['reg_region_name'] = $region_reg;
$fields['reg_city_name'] = $city_reg;
$fields['fact_region_name'] = $region_fact;
$fields['fact_city_name'] = $city_fact;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads;
$fields['passport_code'] = $passport_seriya.$passport_number;
$fields['passport_date'] = $passport_year."-".$passport_month."-".$passport_day;
$fields['passport_title'] = $passport_kemv.", ".$passport_key;
$fields['birthplace'] = $passport_birthplace;
$fields['fact_street'] = 'не указано';
$fields['fact_house'] = '0';
$fields['reg_street'] = 'не указано';
$fields['reg_house'] = '0';
$fields['email'] = $email;
$fields['work_salary'] = $dohod_mes;
$fields['work_organization'] = $work_name;
$fields['work_experience'] = $work_period_month;
$fields['work_phone'] = $work_phone_number;
$fields['fact_housing'] = '0';
$fields['fact_flat'] = '0';
$fields['reg_housing'] = '0';
$fields['reg_flat'] = '0';
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 660;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['lastname'] = $last_name;
$fields['middlename'] = $middle_name;
$fields['birthdate'] = $dry."-".$drm."-".$drd;
$fields['credit_sum'] = $summa;
$fields['credit_days'] = $srok_leads;
$fields['email'] = $email;
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
////////////////////////
unset($fields);
$fields = [];
$fields['token'] = API_TOKEN;
$fields['platform_id'] = API_PLATFORM_ID;
$fields['offer_id'] = 414;
//Обязательные поля
$fields['firstname'] = $first_name;
$fields['mphone'] = "7".$phone_number;
$fields['credit_sum'] = $summa;
$fields['fact_region_name'] = $region_fact;
$fields['fact_city_name'] = $city_fact;
$fields['email'] = $email;
//Необязательные поля
$fields['lastname'] = $last_name;
$url = 'http://webmaster.leads.su/api/leads/push';
$ch = curl_init();
$url = $url . '?' . http_build_query($fields);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$response = json_decode($response, true);
/////////////////////
header('Location: finish.php');
Заявки доставляются только в 1 или 2 кредитных оффера, и только почта почему то, хотя в БД записывается все как нужно.
Что не так помогите пожалуйста.