1
Hello!
I would like help to integrate with webservice via url, for example:
$list_result = '{"titulo": '.
'[{"id":$id_primary}'.
']}';
$json = json_encode($list_result);
//echo $json;
//API Url
$url = 'https://local-que-devo-enviar.com.br/arquivo';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json))
);
//retorno
$jsonRet = json_decode(curl_exec($ch));
var_dump($jsonRet);
- I would like help to understand if I am assembling the data array correctly, how do I get a return and if the code stays that way. 'Cause I’m not getting back from the webservice...
Are you wearing a
json_encode
of something that is already "like" a JSON?!– Inkeliz