14 years 6 months ago
steph.s wrote:
The tweet module uses the twitter api, server side code and client side code don't quite work that way. I will look at the module and see if I can fix the issue though, it might be as simple as not using the correct type urls.
Changing URLs would not help I fear, since page rendering from different sources is the problem.
PHP offers commands, to behave like a client (browser requests). Look at
de.php.net/manual/en/book.curl.php
Like this you can do the API query right from the webserver, where Joomla runs. The twitter API would see the requests coming from this webserver, not from the visitors client/webbrowser. Using this way would make the visitors browser happy on SSL/HTTPS connections (no more complaints about partly unsecure connection).
I do the same for my 3rd party apps, using the EVE Online API:
function QueryAPI($POST,$URL) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POST);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$buf = curl_exec($ch);
curl_close($ch);
return($buf);
}
// set some POST fields
$POST = array(
'parameter1' => 'value1',
'parameter2' => 'value2'
);
// define action URL
$URL = "http://api.someservice.com/callsomething.php";
// execute HTTP query operation, HTML answer results in $buf variable
$buf = QueryAPI($POST,$URL);
As you can see, it is quite simple to suck a HTTP-query answer into server side buffer/array, to do things with it.
Additionally you can cache the answer at the server (by file or database), to prevent brute force queries to the API on high visitor count.
Greets
BlueStar88