Hell Mark.
function newsletter() {
$url = '
http://localhost/eluceo/api/index.php/v1/newsletter/resourcenews';
$today = 'xxxxx';
$data = array('contact' => array('name' => 'nnnnn', 'email' => 'eeee', 'type' => 'iShine'));
$data['newtext'] = 'Welcome to Eluceo!';
$data['captcha'] = $today;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
echo "cURL Error #: " . $error;
} else {
echo "Response: " . $response;
}
echo "\n";
}
I then put the JsonResponse code in the actual code and moved it up the page until it produced some text. That gave me an idea of what was going wrong.
What they have done is all right when using articles etc from the site. But when you have to do alot of processing, for example for mobile phone apps, then it is not very appropriate and I have just made the way I did it on Joomla 3 work for Joomla 4. The work I am doing here is the exchange of information between sites, so only one site has to hold it.
I very much like you idea of having your own library. I will be thinking of that now.