· 7 years ago · Dec 27, 2018, 08:26 PM
1<?php
2
3 //Metodo
4 $method = 'createLeads';
5
6 //Carga útil, parametros, custom fields
7 $params = array("emailAddress" => $datos["email"],
8 "firstName" => $datos["nombre"],
9 "lastName" => "-",
10 "phoneNumber" => $datos["telefono"],
11 "formulario_facebook_5b749611ec967" => $datos['procedencia'],
12 "presupuesto_5b7495176fe16" => $datos['presupuesto'],
13 "__en_qu___ciudad_te_gustar__a_invertir__5b7498212065a" => $datos["ciudad"],
14 "city" => $datos['city']);
15 // Aleatorio
16 $requestID = session_id();
17 $accountID = '<ID DE LA CUENTA>';
18 $secretKey = '<ID SECRETO>';
19
20 //Carga útil
21 $data = array(
22 'method' => $method,
23 'params' => $params,
24 'id' => $requestID,
25 );
26
27 $queryString = http_build_query(array('accountID' => $accountID, 'secretKey' => $secretKey));
28 $url = "http://api.sharpspring.com/pubapi/v1/?$queryString";
29
30 $data = json_encode($data);
31 $ch = curl_init($url);
32 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
33 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
34 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
35 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
36 'Content-Type: application/json',
37 'Content-Length: ' . strlen($data),
38 'Expect: '
39 ));
40
41 $result = curl_exec($ch);