Hey guys and gals. With reference to group post: http://groups.drupal.org/node/19818
I have just finished a gateway module for Txtlocal (http://www.txtlocal.com), and would like it make it available for inclusion in the SMS Framework package. The module was written for 6.x and supports inbound and outbound messaging with all of txtlocal's extended options (specify sender, delayed send, message reference, WAP PUSH).
The module will pass the receiver MSISDN in the $options array to sms_incoming(). I have created a patch request for this core functionality (http://drupal.org/node/397160). I have also written it to the phpdoc header of the module, as below:
* IMPORTANT FOR INCOMING MESSAGES: If you want to use the txtlocal receiver MSISDN
* (inNumber) then the sms_incoming() callback in sms.module must support an
* $options array as a third argument, and must pass this array on to the
* processors. The inNumber is the MSISDN number that received the SMS message.
Cheers all!
Comments
Comment #1
aspope commentedSorry guys, I just realised that the incoming URLs should be below /sms/.
Changed the inbound URLs to /sms/txtlocal/receiver and /sms/txtlocal/receipt
Comment #2
aspope commentedOh no! Found a problem: Line 164 I had implemented
hook_sms_sendwhere I should have usedhook_send. It caused messages to send regardless of whether this gateway was selected, so I was sending through multiple gateways by accident. Sorry about that.Here is an amended version. I have also added a receipt receiver, for if the SMS Framework includes receipt functionality as my feature request (http://drupal.org/node/440384), although it is disabled.
Please review and let me know if you have any suggestions for improvement.
Thanks as always!
Comment #3
andybill commentedBeen using this successfully, thanks!
Until today .. (I've changed my URL to demosite .. , but /webroot/html/ is the root of the Drupal install)
Mar 11 15:36:18 demosite drupal: http://demosite.example.com|1268321778|php|81.158.96.194|http://demosite.example.com/batch?id=14&op=do|http://demosite.example.com/batch?op=start&id=14|1||array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 226.
Mar 11 15:36:18 demosite drupal: http://demosite.example.com|1268321778|backtrace|81.158.96.194|http://demosite.example.com/batch?id=14&op=do|http://demosite.example.com/batch?op=start&id=14|1||Type: php array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 247. Backtrace: array_key_exists(...)[sms_txtlocal.module:247]
Mar 11 15:36:18 demosite drupal: http://demosite.example.com|1268321778|php|81.158.96.194|http://demosite.example.com/batch?id=14&op=do|http://demosite.example.com/batch?op=start&id=14|1||array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 247.
Mar 11 15:36:18 demosite drupal: http://demosite.example.com|1268321778|backtrace|81.158.96.194|http://demosite.example.com/batch?id=14&op=do|http://demosite.example.com/batch?op=start&id=14|1||Type: php array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 250. Backtrace: array_key_exists(...)[sms_txtlocal.module:250]
Mar 11 15:36:18 demosite drupal: http://demosite.example.com|1268321778|php|81.158.96.194|http://demosite.example.com/batch?id=14&op=do|http://demosite.example.com/batch?op=start&id=14|1||array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 250.
Mar 11 15:36:18 demosite drupal: http://demosite.example.com|1268321778|backtrace|81.158.96.194|http://demosite.example.com/batch?id=14&op=do|http://demosite.example.com/batch?op=start&id=14|1||Type: php array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 253. Backtrace: array_key_exists(...)[sms_txtlocal.module:253]
Mar 11 15:36:18 demosite drupal: http://demosite.example.com|1268321778|php|81.158.96.194|http://demosite.example.com/batch?id=14&op=do|http://demosite.example.com/batch?op=start&id=14|1||array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 253.
Any ideas/suggestions? Semi-related, is there a quick /easy way to log which Drupal user is submitting the SMS via this module to Txtlocal?
Andy
Comment #4
aspope commented@andybill, interesting errors. It looks like they are coming from the module enable or similar but I'm not sure where at the moment. I'll have more time to investigate on Saturday morning probably.
About your user logging, you could place a watchdog line in the sms_txtlocal_send function of sms_txtlocal.module. Paste this line above the return line:
watchdog('sms_txtlocal', "Msg to $number with message: $message");
Then you should get events in your Recent Log report.
Comment #5
Durrok commentedDoes Txtlocal work for the US? I couldn't find anything on their site saying if it did or didn't.
Comment #6
aspope commented@Durrok: good question. You should ask them.
Comment #7
Durrok commented@aspope.... thanks... very helpful.
Comment #8
andybill commentedhi aspope,
still getting those errors: the lines in question are:
warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 226.
warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 247.
warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 250.
warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /webroot/html/modules/sms_txtlocal/sms_txtlocal.module on line 253.
The first line is:
if (isset($data) && array_key_exists('options', $data) && array_key_exists('sender', $data['options'])) {
the last three are basically the same call:
if (array_key_exists('url', $data['options'])) {
that are made concerning url, reference and delaymins respectively.
Any ideas where I should start looking?
Andy
Comment #9
aspope commentedHi @andybill, sorry it has taken me so long to reply.
So what is happening here is that the gateway send functions are not receiving the parameters correctly. Is the message actually sending successfully? I will assume not. What is calling the send function - which module/method are you using to send (batch?)? Or is this happening when trying to fetch account balance (on the gateway settings page)?
So in the sms_txtlocal module, the sms_txtlocal_send() function takes the $number, $message and $options (additional params) variables, puts them into an array and passes them to the sms_txtlocal_command() function as a 'sendmsg' operation. The 'if' statements that you have mentioned above (and that I have investigated) are handling the cases where $data does not exist or doesn't contain the item that the condition wants.
To assist troubleshooting, place a line to dump out an error message to the browser when a message is being sent (this might get ugly) in the sms_txtlocal_command() function, just below 'function sms_txtlocal_command(..." place a line like:
watchdog('sms_txtlocal', "Msg to $number with message: $message and data array looks like: ". var_export($data, true));Let me know how you get on. I'm interested in whether this is being triggered intermittently by some bad input or whether it is happening consistently. Thanks!
Comment #10
univate commentedThis this has been committed, this issue can be closed, any should be filed in their own issues.
Comment #12
Roze-1 commentedSubscribing.
Comment #13
univate commentedComment #14
Roze-1 commentedI get the same warnings as
Warning : array_key_exist()[function.array-key-exist]: The second argument should be either an array or an object in sites/all/modules/smsframeworkmodules/sms_txtlocal/sms_txtlocal.module on line 239.
Warning : array_key_exist()[function.array-key-exist]: The second argument should be either an array or an object in sites/all/modules/smsframeworkmodules/sms_txtlocal/sms_txtlocal.module on line 264.
Warning : array_key_exist()[function.array-key-exist]: The second argument should be either an array or an object in sites/all/modules/smsframeworkmodules/sms_txtlocal/sms_txtlocal.module on line 267.
Warning : array_key_exist()[function.array-key-exist]: The second argument should be either an array or an object in sites/all/modules/smsframeworkmodules/sms_txtlocal/sms_txtlocal.module on line 270.
and at the bottom i get "Successfully Sent", but i don't get any messages.