HTTP Requests using SMSsync on Frontline Cloud


#1

Hi,

I’m really struggling to send/receive messages through HTTP requests using SMSsync on Frontline cloud.

I’ve signed up for a free month of Frontline Cloud, with the goal of staying on the paid service if I can get things working.

I have managed to set up a new SMSsync connection, get my URL, and set it up on an Android phone that is syncing sent/received messages with Frontline Cloud.

The next step is to make HTTP requests to the URL so I can send and view received messages from an application that I’m building.

I tried making some send requests through Fiddler:

URL:

https://cloud.frontlinesms.com/api/1/smssync/1111/send

Body:

{
    "secret":"MySecret",
    "message":"Testing from Fiddler",
    "recipients":[
        { "type":"address", "value":"+27000000000" }
    ]
}

I also tried a curl in Windows:

curl.exe https://cloud.frontlinesms.com/api/1/smssync/1111/send
 -H "Content-Type: application/json" -X POST -d "{'secret':'MySecret', 
'message':'Testing from cURL in Windows', 
'recipients':[{'type':'address', 'value':'+27000000000'}]}"

And on linux:

curl https://cloud.frontlinesms.com/api/1/smssync/1111/send
 -H "Content-Type: application/json" -X POST -d "{'secret':'MySecret', 
'message':'Testing from cURL on Ubuntu', 
'recipients':[{'type':'address', 'value':'+27000000000'}]}"

Each of these requests respond with:

{"payload":{"success":"false"}}

I’ve also tried this running Frontline locally, and had the same results.

I’m not sure if I am on the right or wrong track or if I’m just being plain stupid?

Next step would be to get received SMSs via HTTP but one step at a time…

Any guidance would be really appreciated.

Kind regards,
Edward


#2

SMSsync is failing to process the JSON response because it’s not what it expect. If you’re using the task feature, you might want to check the developer docs; http://smssync.ushahidi.com/developers/

Also for SMSsync to acknowledge that web service has received and process the request, it needs to send a {"payload":{"success":"true"}} back to SMSsync.


#3

Thanks for the pointer - I’m getting a success response but no messages seem to be going through.

I changed the POST URL to:
https://cloud.frontlinesms.com/api/1/smssync/1111/MySecret?task=send

And the JSON content to:

{
    "payload": {
        "task": "send",
        "secret":"MySecret",
        "messages": [
            {
                "to":"+270-000-00000",
                "message": "Test SMSsync API",
                "uuid":"random_uuid"
               }
        ]
    }
}

And I keep getting the response: {“payload”:{“secret”:“MySecret”,“success”:“true”,“task”:“send”,“messages”:[]}} - No messages being sent.

Everything else is working so well between SMSsync on the Android phone and FrontlineSMS cloud, I just hope I am on the right track here while trying to trigger SMSs externally…


#4

SMSsync makes a GET request to the web service to pull messages to send out as SMS. So if it makes that request and the messages array is empty, there would be no messages for it to send.

I clicked on the FrontlineCloud link you shared and it’s throwing a 404 error.


#5

Sorry the link I posted did not include my real “secret” or account number since this is a public forum…

I understand that SMSsync on the mobile phone periodically makes GET requests to the SMSsync URL on FrontlineSMS Cloud to get messages. That works fine when I manually create SMSs from within FrontlineSMS Cloud.

What I’m trying to do is create a new message from an arbitrary application running on my local server. Ie post to FrontlineSMS’ SMSsync URL which will save a message on FrontlineSMS Cloud. The cloud will then sync with the SMSsync app on the phone.

The cloud to phone part is working, the post to cloud part is where I’m battling…

I hope this makes sense?


#6

Make sure FrontlineCloud / web service can process the POST request with at least these variables and should return a JSON response with success being true.

from – the number that sent the SMS
message – the SMS
secret – the secret key set on the app

and set something like this; https://cloud.frontlinesms.com/api/1/smssync/1111/MySecret on SMSync.


#7

I get a successful response from the POST like this:

{"payload":{"secret":"MySecret","success":"true","task":"send","messages":[]}}

The success is true but no messages are being returned in the response, and no messages are shown in FrontlineCloud…


#8

If you use a regular http client to make a POST request to FrontlineCloud are the values logged into it?.
Eg.

curl -D - -X POST https://cloud.frontlinesms.com/api/1/smssync/1111/send \ -F "from=+000-000-0000" \ -F "message=sample text message" \ -F "secret=123456" \

On your local server, you should make a POST request with the variables above to FrontlineCloud. FrontlineCloud should process that and you should see it there. This is what SMSsync does. I’m not too sure how FrontlineCloud queues up messages for SMSsync to send as SMS. I’m assuming messages in outgoing/outbox are the ones sent to SMSsync to send as SMS. So make sure when the messages get to FrontlineCloud, they can be queued up for SMSsync to process.


#9

I had to change the url to https://cloud.frontlinesms.com/api/1/smssync/1111/MySecret?task=send otherwise I kept getting a success=false response.

Using those parameters you suggested gave me a response with success=true with an empty message array like I was getting before… Still no messages going through.

The documentation on FrontlineSMS seems a little out of date and there is no obvious contact method. I will try get in touch with their devs, and attempt to document the steps for anyone else wanting to do this if I can get it right…


#10

https://cloud.frontlinesms.com/api/1/smssync/1111/MySecret?task=send is used to process TASK which send messages from the cloud as SMS. You are getting success as true and empty message[] because frontlinecloud hasn’t queued up any messages for SMSsync to send as SMS.

You’re getting a success false when you make a POST to https://cloud.frontlinesms.com/api/1/smssync/1111/MySecret because there might be a missing required variable that frontlinecloud expects. The best is to try and send all the variables as documented here http://smssync.ushahidi.com/developers/

If you successfully send a message to frontlinecloud, I’m sure it’s going to end up in an inbox/incoming list of sort. In that case frontlinecloud won’t queue those messages in the inbox/incoming list for SMSsync to process. You need to figure out how to make the messages in inbox/incoming promoted to outbox/outgoing list so frontlinecloud will queue them up.

It’s good you’re looking into how to contact FrontlineSMS. They would be able to clarify this better than I can.

Not sure if you’ve seen this; https://frontlinecloud.zendesk.com/entries/23727021-Connecting-SMSSync-to-FrontlineCloud Probably it’s outdated

Here is their help desk. You can contact them there; https://frontlinecloud.zendesk.com/home

Thanks for willing to share your solution as you make progress with this. Let’s know how it goes.


#11

Thanks for the pointer - I’m getting a success response but no messages seem to be going through.

http://imgupp.com/img/1434586608.jpg


#12

RealY I do not know HTTP requests using SMS sync on Frontline
But I sort of began to understand