Traccar SMS Gateway

TSGondim4 years ago

hi guys,
About Traccar SMS Gateway...
is it running?
I tried to test with a html form and curl in php but didn't have any response!

Anton Tananaev4 years ago

Have you enabled the gateway is in the app?

TSGondim4 years ago

Yes, I did!
This gave me an api_key that I put as authorization in the header!

Note: Congratulations for the project! Very useful!

Anton Tananaev4 years ago

Can you connect locally on the phone?

TSGondim4 years ago

I tried from my remote server!

I enabled the smartphone's gsm data and I didn't use the local ip!

how can I do, that?!

TSGondim4 years ago
<?php
$phone = $_POST['to'];
$text = $_POST['message'];
$enviar = $_POST['enviar'];//my submit button
$api_key = 'My api key';
  if (isset($enviar)) {
$url = 'http://my mobile IP:8082';

$data = array(
    'to' => $phone,
    'message' => $text,
);
$curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_HTTPHEADER, array(
            "Authorization: " . $api_key 
                                                    )
                    );  }
               
$response = curl_exec($curl);
$obj = json_decode($response, true);
var_dump($response);
Anton Tananaev4 years ago

What I'm saying is that you should probably try locally first. That will confirm if the app is working correctly.

TSGondim4 years ago

Okay!
Thank you! I'll try!
At the moment, I don't have a computer running php that I could do this post request locally!
Thanks for your attention!

TSGondim4 years ago

I can access the phone's ip with port 8082 and see the app message!

TSGondim4 years ago

only with local ip

Anton Tananaev4 years ago

If it's accessible with local IP, it means that the app is working. I guess the issue is with your network.

davejh4 years ago

Jus in case anyone is interested. I have the gateway app working with my remote server. All I did was put my router public ip which is static in the traccar config. then port forward my router public ip in the router settings to the phone ip 192.168.1.75:8082. works perfect every time.

davejh4 years ago

@TSGondim did you get your php code working?

<?php
$phone = $_POST['to'];
$text = $_POST['message'];
$enviar = $_POST['enviar'];//my submit button
$api_key = 'My api key';
  if (isset($enviar)) {
$url = 'http://my mobile IP:8082';

$data = array(
    'to' => $phone,
    'message' => $text,
);
$curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($curl, CURLOPT_HTTPHEADER, array(
            "Authorization: " . $api_key 
                                                    )
                    );  }

$response = curl_exec($curl);
$obj = json_decode($response, true);
var_dump($response);
Adrian2 years ago

i can't send message with above code, i get error

string(10) "Error: 500"