Correct CURL syntax

Pushsafer make it easy and safe to get push-notifications in real time on your Android or Windows mobile device, iPhone, iPad and Desktop!

Mit Pushsafer kann man in Echtzeit, einfach und sicher, Push-Benachrichtigungen auf sein iPhone, iPad, Android oder Windows Gerät sowie auf den Desktop senden lassen!

======================
Google Play
App Store
Windows 10 Store
Homepage
Lloyd_80
Posts: 4
Joined: 15. Aug 2018, 14:43

Correct CURL syntax

Postby Lloyd_80 » 15. Aug 2018, 14:51

Hi there! I need to activate specific push-notifications via CURL. I've been tried different syntax but no succeed. If I paste pushsafer generated link in browser everything works fine, but trying to do same via CURL gives no effect. What syntax should I use in CURL to succed?

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: Correct CURL syntax

Postby admin » 15. Aug 2018, 15:03

Hi,

here you will find some examples incl. CURL from PHP or Command Line.

https://www.pushsafer.com/en/pushapi

What programming language you use?

Kevin
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

Lloyd_80
Posts: 4
Joined: 15. Aug 2018, 14:43

Re: Correct CURL syntax

Postby Lloyd_80 » 16. Aug 2018, 08:20

Hi Kevin!

I'am using .bat file in Win10. Some event activate .bat file via cmd.exe. This .bat contains Pushsafer-generated link. When I paste this link manually in browser, it works. But when I try to activate it via .bat nothing happens. I guess there is some kind of issues with UTF-8 charset probably. There is code I using in .bat:

Code: Select all

curl --header "Content-Type: text/plain" --request PUT --data "OFF" https://[pushsafer_generated_URL]
exit

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: Correct CURL syntax

Postby admin » 16. Aug 2018, 08:56

Hi,

set the url in quotes, then it works

Code: Select all

curl --header "Content-Type: text/plain" --request PUT --data "OFF" "https://www.pushsafer.com/api?k=XXXXXXXXXXXXXXXXXXXX&d=XXX&i=10&c=%23ffd699&v=3&pr=2&a=1&t=test&m=test"
Kevin
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

Lloyd_80
Posts: 4
Joined: 15. Aug 2018, 14:43

Re: Correct CURL syntax

Postby Lloyd_80 » 16. Aug 2018, 10:22

Thanks Kevin!
So damn simple:) It works, but there is another problem. When I send push notification this way in latinic characters, it comes with 0 instead of spaces, for example "Motion0in0garage!". And when I try to send notification with cyrillic characters I receive sometging like this "BBE9FBEB4DBA19...". Is there any way to solve it? I really need to send cyrillic pushes

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: Correct CURL syntax

Postby admin » 16. Aug 2018, 11:05

great that it works now.

You have to encode these characters
For static sending, you can use our url encoder:
https://www.pushsafer.com/en/url-encoder-decoder

Otherwise you can use this:

Code: Select all

chcp 1252>nul
curl --header "Content-Type: text/plain" --request PUT --data "OFF" "https://www.pushsafer.com/api?k=XXXXXXXXXXXXXXXXXXX&d=XXX&i=10&c=%23ffd699&v=3&pr=2&a=1&t=test&m=АБВГДЕЖ"
chcp %cp%>nul
exit
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10

Lloyd_80
Posts: 4
Joined: 15. Aug 2018, 14:43

Re: Correct CURL syntax

Postby Lloyd_80 » 22. Aug 2018, 07:33

Still doesn't work and I can't understand what I'am doing wrong:(
Well, when I encode cyrillic characters separately with your encode/decode tool, and paste encoded result to the link, I get API response {"status":0,"error":"invalid key or empty message"}
And when I using your CURL example, where I insert nonencoded cyrillic characters, it coming to phone with "9BBEBBEBBBE" again.
Let me explain my case: my soft in different situations can trigger different Windows batch files with Pushsafer pre-generated links, custom for each situation. Email triggers is kinda slow and can't show cyrillic characners too. May be I can use different CURL construction/syntax or command? Batch file is preferred for me, but also I can use vbs scripts instead of bat.

User avatar
admin
Site Admin
Posts: 331
Joined: 1. Dec 2014, 12:41
Location: Germany

Re: Correct CURL syntax

Postby admin » 22. Aug 2018, 07:37

can you send me your bat file by mail! I will check

Kevin
DE: Dir gefällt Service und Support! Dann freuen wir uns auf deine Bewertung!
EN: You like Service and Support! Then we look forward to your review!

Pushsafer.com Website - iOS - Android - Windows 10


Who is online

Users browsing this forum: No registered users and 1 guest