ccc

CURL: Mandar Json con autentificación

$data = array(
"phone" => "666666666",
"name" => "prueba"
);

$datosJSON = json_encode($data);
$authorization = "Authorization: Bearer eyJhbGciOiJIUzIxxxxeyJweWkiOjI3LCJzb3UiOjEsInR5cCI6OTZ9.uHryI1VKA1uoPgj1rvb5b6BXuBaI0KCTLurnsaOGaFQ";
$api_url = "https://api.loquesea/lead";
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$datosJSON);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);

No hay comentarios:

Publicar un comentario