When configuring the gateway the following fields are all set to required.
I am under the impression that you use a field name OR a value.
"Username field name" and "Username field value"
"Sender (from) field name" and "Sender (from) field value"
"Extra parameters"

Comments

joncup created an issue. See original summary.

alansaviolobo’s picture

Status: Active » Closed (won't fix)

Your suggestion would make sense if this module catered to a specific gateway.
In that case, fields such as "Sender (from) field name", "Username field name" etc would not be required as those strings would be fixed.

But this is a generic module that caters to many gateways and hence those fields need to be configurable.
one gateway may prefer to use the term "username" while another might prefer "user" or even "authkey".

The other fields like "Username field value" & "Sender (from) field value" are provided by the gateway when you signup for an account.

joncup’s picture

Well, the way it is now, you are forced to fill out all of those fields, even an optional one in order to submit the form. You cant save it with out filling out the "extra parameters" field. Isn't that optional?

alansaviolobo’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new651 bytes

You are correct. the extra parameters field should be optional. I have created a patch for the same.
I believe the other fields are ok.

joncup’s picture

Cool, also thank you. I understand why the field names are required now. That's a big help.

alansaviolobo’s picture

Sorry, I didn't understand 'inbound implemented'. are you referring to the ability to accept incoming sms ?
If so, yes, the capability is present, However, I don't have a gateway handy to test it.

joncup’s picture

Also, just past line 242, it's still sending an extra & and the empty extra veriable when doing the request I think.

I will try to test incoming.

joncup’s picture

So, over here around line 244, its this last bit of code ". '&' . $this->configuration['extra_params']". I had to remove it to get it to work, because of the undefined exta_params. I'm not sure how, but I think that last bit needs a check to see if it needs to get sent.
Also, in testing now I get a 401 error from my provider (flowroute, here's their API documentation http://developer.flowroute.com/api/messaging/overview/ ). The gateway uses HTTP Basic Auth. I have a feeling we're looking for the username field, but that isnt part of the string, its HTTP Basic Auth.

 $query_string = http_build_query(array_filter([
        $this->configuration['user_field'] => $this->configuration['user_value'],
        $this->configuration['pass_field'] => $this->configuration['pass_value'],
        $this->configuration['sender_field'] => $this->configuration['sender_value'],
        $this->configuration['number_field'] => $this->configuration['number_prefix'] . $sms->getRecipients()[0],
        $this->configuration['message_field'] => $sms->getMessage(),
      ])) . '&' . $this->configuration['extra_params'];
alansaviolobo’s picture

I have verified your issue on my own gateway. for a GET request, the extra & doesn't make a difference.
Apart from the issue that you have mentioned, I see that the gateway accepts a POST request and that the contents are json encoded.
I am now checking the structure of the POST request.

joncup’s picture

any idea about the http auth? I'ts working better now, but now my error is from my gateway. also, even if your gateway doesnt throw an error, maybe you shouldnt be sending extra parameters. i was getting undefined variable errors until I removed that last part.

joncup’s picture

Also, I don't think the & is the problem, I think its the undefined variable error as the module expecting a value and not having one.

alansaviolobo’s picture

I have put in two more options for "authorization" and "content types" for POST request.
as per the api for FlowRoute, you would have to pick the options - basic & json respectively.

wrt the notices, they appear the first time you are configuring a form since there are no default values. editing the form subsequently does not throw any errors. will work on them.

joncup’s picture

Hooray! It is working. I got my first text messages from my website!

alansaviolobo’s picture

woot!

alansaviolobo’s picture

did you get an opportunity to test out the incoming message feature ?

joncup’s picture

Ohh, I had a question. How does incoming work. I have my callback url set on flowroute but i don't understand how to test incoming and where it goes.

alansaviolobo’s picture

StatusFileSize
new34.32 KB

as per http://developer.flowroute.com/docs/receive-an-inbound-message/, the configuration here would be "from", "body" & "to"
config

as per https://www.drupal.org/docs/7/modules/sms-framework/processing-incoming-messages, you would then have to implement a hook_sms_incoming($op, $number, $message, $options).
in this hook, you can take an appropriate action depending on the text of the message. the simplest action would be to send an outgoing sms acknowledging to the user that their message has been received and acted upon.

alansaviolobo’s picture

Assigned: Unassigned » alansaviolobo
Status: Needs review » Fixed
StatusFileSize
new1.56 KB

I have attached a test module to that logs every incoming sms.
you should be able to use it along with the configurations mentioned here - http://developer.flowroute.com/docs/receive-an-inbound-message/

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

johnhuang0808’s picture

@alansaviolobo, my SMS service provider doesn't have any sender(from) field. Could we make this as an optional field?
For example, adding a checkbox to let user decides the gateway should have sender(from) field or not. If the checkbox is not checked, the form doesn't validate it and the send action also doen't include the parameter.

alansaviolobo’s picture

That is strange. If this is not passed as a parameter, then maybe you are configuring it in your account settings.
can you point me to your gateway documentation please ?

johnhuang0808’s picture

Of course! Here is the gateway documentation in English.

Thanks a lot.

alansaviolobo’s picture

done. check the dev version.

johnhuang0808’s picture

Thanks @alansaviolobo, it works for me.