All I want to be able to do is launch that http call from within a php page for now and I am damned if I can see how to do it. (It cab be php, perl, ruby,bash or a couple of other languages)
(BTW I also realised in my test set up I was using JS and I presume that JS will NOT work if it is essentially running on GoDaddys servers. That is a side question.)
Sorry for the hugely dumb questions.
I have spent literllaly hours looking for this and the answer may be buried here but I cannot see it.
Thanks in advance for any gentle help.
Aloha Steve
Probably the most common way to do this within a PHP script is to use the cURL functions. It can get a bit fiddly at times if you have to mess around with a bunch of "setopt" parameters, but if you're lucky, it might be as simple as something like:
PHP Code:
$url = "http://clickatell.com/api/123?password=".urlencode($password)."&telephone-no=".urlencode($telephone)."&msg=".urlencode($message); $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); // do stuff with $result....
That was typed from memory, so may be wrong, incomplete, etc....
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
NogDog well the system just ate my reply so here goes again.
First thanks for your prompt reply but I think this is NOT quite what I am trying to do.
I am not trying to edit the api call AT ALL at this stage I am just trying to do a call and get a text sent - I can build from there.
For starters I can use JS or whatever to rewrite the file that the CRON job fires off.
As for cURL, is that part of the base release of PHP 5.3? I saw somewhere I had to edit my php.ini file to get it working but there is no mention of cURL in the ini file. Anyway that really is a question for another day.
Oh I remember the second part of my previously eaten question. I am assuming that any Javascript in a PHP page read as the CRON script on a GoDaddy server will be ignored. Am I right in that I assume that? Just helps in the controls I can use on the page.
Once again pls forgive my ignorance and thanks for the pointer.
The point is that cURL is used to send HTTP requests directly from within your executing PHP script to whatever URL you want, which is typically what you want to do when accessing an API. I was just giving an example of how you might dynamically build a URL string (being sure to url-encode things that might have to be encoded) in order to create the URL to be transmitted. Normally you don't want to send the exact same request data every time -- usually there is something dynamic going on -- if not, then just ignore that part.
As to whether or not cURL is enabled in your installation, I have no way to know. I suppose you could just try a simple script that tries to do a curl_init(), and see if it blows up or not. If it is, in fact, not enabled/installed, then the options are to get it installed, find out if the url_fopen option is enabled (usually not due to security issues) and just put the url into a file_get_contents() call, or switch to another host.
Or the other alternative is that I'm totally misunderstanding the situation and what you want to do.
As for JavaScript that is output by a PHP script: yes, it only gets run by the client (typically a web browser) when it receives the output from your PHP script.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
The point is that cURL is used to send HTTP requests directly from within your executing PHP script to whatever URL you want, which is typically what you want to do when accessing an API. I was just giving an example of how you might dynamically build a URL string (being sure to url-encode things that might have to be encoded) in order to create the URL to be transmitted. Normally you don't want to send the exact same request data every time -- usually there is something dynamic going on -- if not, then just ignore that part.
As to whether or not cURL is enabled in your installation, I have no way to know. I suppose you could just try a simple script that tries to do a curl_init(), and see if it blows up or not. If it is, in fact, not enabled/installed, then the options are to get it installed, find out if the url_fopen option is enabled (usually not due to security issues) and just put the url into a file_get_contents() call, or switch to another host.
Or the other alternative is that I'm totally misunderstanding the situation and what you want to do.
As for JavaScript that is output by a PHP script: yes, it only gets run by the client (typically a web browser) when it receives the output from your PHP script.
You, sire, are a gentleman (or lady!!!!)
I hacked the code a bit went away and more by chance came up with:
Bookmarks