Looking for help to code SMS send function Clickatell

ontarget

Active Member
Hi
I have several clients using clickatell sms gateway who provide a number of API's including php
https://archive.clickatell.com/developers/scripts/php-library/
PHP:
use Clickatell\Api\ClickatellHttp;

$clickatell = new ClickatellHttp($username, $password, $apiID);
$response = $clickatell->sendMessage(array(1111111111), "My Message");

foreach ($response as $message) {
echo $message->id;
// Message response fields:
// $message->id
// $message->destination
// $message->error
// $message->errorCode

}
I have a fabrik list which has a list of people attending events which include their mobile numbers.
Does anyone have any experience of selecting / filtering a list of users and phone numbers - converting them to an array that would load in the $clickatell->sendMessage(array()
Would this be the correct method?
http://fabrikar.com/forums/index.php?wiki/common-php-tasks/ See Load an array of rows as objects:

I was thinking of creating a form with
Dropdown = Select event (eventName) database join field
Textarea = Enter message
Button = Send Message

php on form process plugin

PHP:
/ Get a db connection.
$myDb= JFactory::getDbo();

// Create a new query object.
$myQuery=$myDb->getQuery(true);

$myQuery
   ->select(array('telephone'))
   ->from('myEventsTable')
   ->where('eventName = '.$myDb->quote('value selected in dropdown'));

// Assign the query to the db
$myDb->setQuery($myQuery);

// Load the results as an array of objects.
$rows=$myDb->loadObjectList();

Then also somehow call the clickatell php stuff above (thats whereI'm stuck!)
If you can help me a get a solution I will happily post the code up to the Wiki
 
If you'd like to take out a Pro sub I'd be happy to integrate it into our SMS helper and Composer libraries, so it would be available automatically in the list and form plugins.

-- hugh
 
Perfect thanks Hugh - yes I will do that - just to confirm will I be able to filter a list of users based on a criteria like "Event" then send them a SMS?
 
Yes. The list email plugin also supports SMS, so you can filter the list how you want, select the rows you want, and hit the button.

-- hugh
 
Hi Hugh,
I have taken out the pro subscription if you could please setup the clickatell plugin.
Thanks
 
Did you read my previous message?

I need to know whether I'm using the legacy (pre Nov 2016) or new API. I can only use one. Or rather, if I have to account for both of them, that's a lot more work.

-- hugh
 
Sorry missed that - i will check it out - looks like the clickatell account was setup in 2013 shall i pm you access?
 
OK, I've added the new gateway. You'll need to do a full github update to pick up the new Composer library as well.

I added a REST API in your Clickatell dashboard. You'll need to get the token from that ("INFO AND HELP" link for the REST API). You can then put that in either the Username or Password field in the SMS plugin settings, and leave the other blank. The Clickatell API doesn't use both (they are all different, some use "sid" and "token", some use "username" and "password", this one just uses a token).

I suggest you test it out using the form SMS plugin first, before trying the list plugin.

Note that the Clickatell API doesn't seem to support setting a "From" number when sending, I guess it just uses whatever your account is set up with. So ignore that setting in the plugin.

Also note that numbers have to have their international prefix, but without leading 0's. So a US number would be 11 digits ... 1xxxyyyyyyy (1, area code, number). Without the inyternation prefix, it'll throw a "invalid destination" error.

Also also note that I didn't receive the test text I sent to myself, even though the API returned a success status. Looking at your dashboard, it failed with a "routing error", even though it correctly identified my carrier as Verizon.

Let me know how your test goes.

-- hugh
 
Hi Hugh
Just testing the clickatell integration with the form plugin (form is set to not save to DB)
On entering a message into a textarea element {___message} then clicking submit I get the following error:

Fatal error: Class 'Clickatell\Api\ClickatellRest' not found in /home/otwddevacc/public_html/blackrockec/libraries/fabrik/fabrik/Helpers/sms_gateways/clickatell.php on line 51

I tried hard coding in the token too but same error.

PHP:
    //$client = new ClickatellRest($token);

        $client = new
ClickatellRest('1Wxxxxxxxxxx.xxxxxxxxxxxxx');


The SMS Form plugin settings are as follows:

Username = blank
Password = 1Wxxxxxxxxxx.xxxxxxxxxxxxx (the Auth Token value)
Receivers mobile number = 353861234567
sms message = {___message}

any ideas please?
thanks
 
Hi Hugh
Just testing the clickatell integration with the form plugin (form is set to not save to DB)
On entering a message into a textarea element {___message} then clicking submit I get the following error:

Fatal error: Class 'Clickatell\Api\ClickatellRest' not found in /home/otwddevacc/public_html/blackrockec/libraries/fabrik/fabrik/Helpers/sms_gateways/clickatell.php on line 51

I tried hard coding in the token too but same error.

PHP:
    //$client = new ClickatellRest($token);

        $client = new
ClickatellRest('1Wxxxxxxxxxx.xxxxxxxxxxxxx');


The SMS Form plugin settings are as follows:

Username = blank
Password = 1Wxxxxxxxxxx.xxxxxxxxxxxxx (the Auth Token value)
Receivers mobile number = 353861234567
sms message = {___message}

any ideas please?
thanks
Did you do a GitHub update? If not, did you install / update the Fabrik library (from downloads)?

Hugh


Sent from my Nexus 7 using Tapatalk
 
Looks like there was an update to the Clickatell helper in Github 13 days ago that you need to update. Then try it again and repost if you still have an error.
 
No, I mean a full github update - everything. The files you need are in ./library/fabrik, and you can't cherry pick them.

-- hugh
 
sorry! - ok i overwrote the whole libraries dir from git - some progress I am now getting

Error
SMS failed with error code:

Message
Record added/updated

There is no error code provided however!

==============================

Update
I just did a full git update - everything not just libraries same error.
I also tried storing the form data to a db table but the same error persists
 
Last edited:
Ah, well, that's because I'm a dumbass. Should be fixed in this commit:

https://github.com/Fabrik/fabrik/commit/40826ddeecc48221c2e82b5c19f71841be408b23

You can just grab that one file.

It should have sent your SMS, by the way. I just had the test wrong, so a non-error was being treated as an error.

Note that when I test, although I get a 'success' response, I never actually get the text, and looking in your Clickatel dasjboard, it's complaining about a network failure to Verizon (my carrier).

-- hugh
 
Back
Top