Hi I have this code I am trying to send a string and an array to an api but I do not receive any error and I can not make it work.
Can someone help me and tell me what I'm doing wrong?
this is my code:
<?php
$url = "https://example.url/api/links/create?api_token=lpwuF8R7A6y41fg64fdgvBydQX6T7I64waaPf";
$curl = curl_init();
$params = json_encode([
'long_url' => $lnk,
'rules' => '{key: "us", value: "https://destination.us", type: "geo"}',
]);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $params,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Content-Length: ' . strlen($params)
]
]);
$response = json_decode(curl_exec($curl));
curl_close($curl);
// $response can now be used, see above for how it's formate
$data2 = $response;
?>