简体   繁体   中英

How to send a curl request using the command line in Windows

I need send a curl request to get a push notification from apple, I am try do it using node.js and the command line, but when I send it I do not have any notification on my device, only is I use an external json.txt, but need send this json object in the command line itself.

my first example it don't work

 let args = `-v -d '{\"aps\":{\"alert\":{\"title\":\"SENT_BY_NAME\",\"subtitle\":\"MESSAGE\",\"body\":\"MESSAGE\"},\"badge\":1,\"sound\":\"default\"}}' -H Content-Type:application/json -H apns-topic:com.myapp.ios -H apns-expiration:1 -H apns-priority:10 --http2 --cert apple_push_notification_certificate.pem:pass https://api.push.apple.com:443/3/device/tokenofdevice`;

this example work but I need some similar to my first example

 let args = `-v -d @json.txt -H Content-Type:application/json -H apns-topic:com.myapp.ios -H apns-expiration:1 -H apns-priority:10 --http2 --cert apple_push_notification_certificate.pem:pass https://api.push.apple.com:443/3/device/tokenofdevice`;

this new to me need some help thanks

尝试将JSON字符串括在双引号中:

... -d "{\"aps\":{\"alert\":{\"title\":\"SENT_BY_NAME\",\"subtitle\":\"MESSAGE\",\"body\":\"MESSAGE\"},\"badge\":1,\"sound\":\"default\"}}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM