/    Sign up×
Community /Pin to ProfileBookmark

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

[url]http://clickatell.com/api/123/password=x/telephone-no=2121234568&msg=hello[/url] dolly

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

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 01.2013 — Probably the most common way to do this within a PHP script is to use the [url=http://php.net]cURL[/url] 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:
[code=php]
$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....
[/code]

That was typed from memory, so may be wrong, incomplete, etc.... ?
Copy linkTweet thisAlerts:
@stevehomerauthorMar 02.2013 — 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.

Aloha Steve
Copy linkTweet thisAlerts:
@NogDogMar 02.2013 — 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.
Copy linkTweet thisAlerts:
@stevehomerauthorMar 02.2013 — 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.[/QUOTE]


You, sire, are a gentleman (or lady!!!!)

I hacked the code a bit went away and more by chance came up with:

[code=php]
<?php
$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);
curl_exec($ch);
curl_close($ch);

echo $result;



?>[/code]


I cannot tell a lie I am not really sure what I am doing but it worked.

Now I have to try and get my head around php and MySQL and Javascript to bring it all together :-(

Thanks for the pointer.

Aloha Steve
×

Success!

Help @stevehomer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...