send sms

jack s4 years ago

Hello,
how can I send sms using https API like this:
HTTPs:

https://bms.xxx.sy/API/SendSMS.aspx?user_name=Normal123&password=P@ss_1234&msg=TestMSG&sender=NEWS&to=963993678389;963997965751;
Anton Tananaev4 years ago

It's not supported.

jack s4 years ago

It's done thank you.

jack s4 years ago

this is the code and configuration:

    <entry key='notificator.sms.manager.class'>org.traccar.sms.HttpSmsClient</entry>
    <entry key='sms.http.url'>https://bms.xxxx.sy/API/SendSMS.aspx</entry>
    <entry key='sms.http.template'>
       user_name=Normal123&amp;password=P@ss_1234&amp;msg={message}&amp;sender=NEWS&amp;to={phone};
    </entry>
    @Override
    public void sendMessageSync(String destAddress, String message, boolean command) throws MessageException {
        Response response = getRequestBuilder(preparePayload(destAddress, message)).get();
        if (response.getStatus() / 100 != 2) {
            throw new MessageException(response.readEntity(String.class));
        }
    }

    private Invocation.Builder getRequestBuilder(String params) {
        return Context.getClient().target(url + "?" + params).request();
    }
Anton Tananaev4 years ago

It would be great if you could clean up the solution a little bit, make it configurable and send a PR.

jack s4 years ago

Ok, I'll do that.

davejh4 years ago

Hi Jack i'm trying to understand what you are doing here. can you explain please. is this to send sms commands as well as notifications? thanks