Have you enabled the gateway is in the app?
Yes, I did!
This gave me an api_key that I put as authorization in the header!
Note: Congratulations for the project! Very useful!
Can you connect locally on the phone?
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?!
<?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);
What I'm saying is that you should probably try locally first. That will confirm if the app is working correctly.
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!
I can access the phone's ip with port 8082 and see the app message!
only with local ip
If it's accessible with local IP, it means that the app is working. I guess the issue is with your network.
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.
@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);
i can't send message with above code, i get error
string(10) "Error: 500"
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!