GoDaddy Cron job http api call - really dumb question
OK I haven't programmed (apart from HTML - is that really programming???) for over 20 year.
Trying to get back up to speed. Getting just about there in JS but want to use CRON to launch a process at GoDaddy.
I have an account with Clickatell. They send SMSs by a v simple HTTP call eg
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.
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:
That was typed from memory, so may be wrong, incomplete, etc....
$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....
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.
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.
You, sire, are a gentleman (or lady!!!!)
Originally Posted by NogDog
I hacked the code a bit went away and more by chance came up with:
I cannot tell a lie I am not really sure what I am doing but it worked.
$url = 'http://api.clickatell.com/http/sendmsg?user=fffffffffff&password=xxxxxxx&api_id=xxxxxx&from=999999999&mo=1&to=99999999&text=Rebecca%20CRON%20loves%20you!';
$ch = curl_init($url);
Thanks for the pointer.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)