Page 2 of 3
Re: arduino pushsafer can't compile
Posted: 8. Jan 2017, 20:04
by admin
Content lenght is not the problem
out of the box arduino does not seem to support secure connections over https.
http://stackoverflow.com/questions/1583 ... ps-support
Please try to replace
https://www.pushsafer.com to
http://www.pushsafer.com
Otherwise you have to use a third party library for secure connections:
http://stackoverflow.com/questions/1113 ... on-arduino
Re: arduino pushsafer can't compile
Posted: 8. Jan 2017, 20:17
by robomaniac
ok check this out.
When I write
Code: Select all
client.println("Host: http://www.pushsafer.com");
I get error message 'bad request'
BUT when I write
Code: Select all
client.println("Host: www.pushsafer.com");
I get no message at all. Just "Connected"
to make sure http works, I use your code generator like this
Code: Select all
http://www.pushsafer.com/api?k=KEY&d=1422&i=9&v=3&m=Message
and that did work
Re: arduino pushsafer can't compile
Posted: 8. Jan 2017, 20:33
by admin
an pushsafer api request have to sent over a secure connection.
When you do a normal http request (without POST variable) the server make a redirect to a https connection.
But this do not seem to work while using a POST request.
So you have to use a third party library for https connection.
Or you do a GET request by appending all variables to the API URL like the URL generator do.
Re: arduino pushsafer can't compile
Posted: 8. Jan 2017, 20:44
by robomaniac
ok thanks
I will try the GET since I did make that work on a other project, I was talking to PHP file on my server and he was sending email.
it look like this
Code: Select all
client.println("GET /send_email.php?temperature="+temperature+"&humidity="+humidity+" HTTP/1.1"); //Send data
in our case we do something like this
Code: Select all
client.println("Host: http://www.pushsafer.com");
client.println("GET /api?k=key&d=1927&i=9&v=3&m=Message HTTP/1.1");
will play with that and let you know.
Also went I have time, will try the library for secure connection.
Re: arduino pushsafer can't compile
Posted: 8. Jan 2017, 20:49
by robomaniac
oh
I now have this message with the GET
Code: Select all
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https:///">here</a>.</p>
<hr>
<address>Apache Server at www.pushsafer.com Port 80</address>
</body></html>
when I send to HTTPS
Code: Select all
client.println("Host: https://www.pushsafer.com");
client.println("GET /api?k=key&d=1927&i=9&v=3&m=Message HTTP/1.1");
I get this
Code: Select all
....................................Connected
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
<h1>Method Not Implemented</h1>
<p>Host: to /index.html not supported.<br />
</p>
<hr>
<address>Apache Server at default Port 80</address>
</body></html>
Re: arduino pushsafer can't compile
Posted: 8. Jan 2017, 20:53
by admin
This message over http
is normal, because the redirecting from http to https
do you get a notification to your device?
Re: arduino pushsafer can't compile
Posted: 8. Jan 2017, 21:01
by robomaniac
admin wrote:do you get a notification to your device?
no, trust me, when I get notification, you will be the first to know
I am trying different ways using GET, I am not very familiar with web request, formating, etc.
Re: arduino pushsafer can't compile
Posted: 10. Jan 2017, 09:10
by admin
Hi robomaniac,
sorry for the late reply.
Now you can access the api via http or https.
Please take a try and give me a feedback!
Thanks Kevin
Re: arduino pushsafer can't compile
Posted: 11. Jan 2017, 02:11
by robomaniac
Hi Kevin,
My name is Jerome btw
I got your message and I am trying hard to get this to work. I have tested lots of stuff so I will clean my code and try again.
Right now, I have this and lots of bad request.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.pushsafer.com/data/push-send.php">here</a>.</p>
<hr>
<address>Apache Server at pushsafer.com Port 80</address>
</body></html>
I will focus using this instead, with this, I don't have other bad variable. does it make sense? Is there mistake?
Code: Select all
client.print("Content-Length: ");
client.print(length);
client.println("\r\n");;
client.print("k=insert_my_key");
client.print("&m=message");
client.print("&t=title");
client.print("&s=2");
client.print("&v=3");
client.print("&i=3");
client.print("&d=a");
client.print("&retry=60");
client.print("&expire=3600");
Tonight I will try other things and keep you updated. Thanks.
Re: arduino pushsafer can't compile
Posted: 11. Jan 2017, 03:27
by robomaniac
oh oh!
I just got message saying "
below message limit, to expand your message capacity, go to your pushsafer dashboard..."
I was checking my last code and verifying
Code: Select all
https://www.pushsafer.com/api?k=insert_my_key&m=message&t=title&s=2&v=3&i=3&d=a&retry=60&expire=3600
with this
Code: Select all
client.print("k=insert_my_key");
client.print("&m=arduino");
client.print("&t=enfin");
client.print("&s=2");
client.print("&v=3");
client.print("&i=3");
client.print("&d=a");
client.print("&retry=60");
client.print("&expire=3600");
to make sure I understand the creating of a link via GET