How to send logcat by curl POST command - android

Need to send by shellscript every new string in Android logcat by curl POST command to server. Connected to Android by ADB.
I was trying this things:
#logcat com.mm.en:I -e "chat"| tee /sdcard/Pictures/out.txt
It makes a file, and write every new string to it.
Next i was trying:
#curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST http://nnnn.ru/test/testprint.php -G -d '{"id":"IDVALUE","name":"Mike"}'
It is also work.
But when i trying to combine it by guide, it doesnt work:
#logcat com.mm.en:I -e "chat"| curl -H 'Content-Type: application/json' http://nnnn.ru/test/testprint.php -d #-
Where i`m wrong?

Related

curl command is not executing push notification using pusher

I am working on Android application using ESP32. I want a system, where, when I press button (hardware button) it send a notification to an android app. I have connected the data to firebase and used pusher to send notification. My device is integrate. But, I am unable to execute push notification curl command.
When I execute curl command (I even downloaded curl.exe and set the path):
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer **Secret Key**" \
-X POST "https://**Instance ID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" \
-d '{"interests":["hello" ,"fcm":{"notification":{"title":"Hello", "body":"Hello, world!"}}}'
I got error in command prompt, like this:
C:\Windows\system32>curl -H "Content-Type: application/json" \
curl: (6) Could not resolve host: \
C:\Windows\system32> -H "Authorization: Bearer **Secret Key**" \
'-H' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32> -X POST "https://**Instance ID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" \
'-X' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\system32> -d '{"interests":["hello"],"fcm":{"notification":{"title":"Hello", "body":"Hello, world!"}}}'
'-d' is not recognized as an internal or external command,
operable program or batch file.
The entire block should be a single command, but it seems your command line is executing a line at a time.
Try the below, which I should run as a single line command
curl -H "Content-Type: application/json" -H "Authorization: Bearer **Secret Key**" -X POST "https://**InstanceID**.pushnotifications.pusher.com/publish_api/v1/instances/**Instance ID**/publishes" -d '{"interests":["hello" ,"fcm":{"notification": "title":"Hello", "body":"Hello, world!"}}}'

Android - Curl command to Volley Request

I have curl request to push data to the server from Android.Below is the Curl request:
curl -v -H "Accept: application/json" -H "Content-type: application/json" -H "Authorization: Token token=SNKh9UP4RX2Ltyxo9JnG , username=local1admin" -X PATCH -d '{"fcm": {"token":"sd7sdf6sdffd5"}}' http://myapp-back.herokuapp.com/fcms/1
How should I do post request using volley? I am confused because I have no idea where to put this:
'{"fcm": {"token":"sd7sdf6sdffd5"}}'
So please anyone help me to get it done. Any answers are appreciable. Thank you.
Peace out!
I ran into similar issue with my curl command below -
curl 'https://ws.test.com/handle_email?embed_load_code=undefined' -H 'Accept: /' -H 'Referer: https://cdn1.test.com/widgets/12345/12345/widget.html' -H 'Origin: https://cdn1.test.com' -H 'User-Agent: Test App' -H 'DNT: 1' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' --data 'campaign=12345&merchant=12345&original_data=%257B%2522site%2522%253A%2522site-11111-www.test.com%2522%257D&share_id=&email=test%40test.com' —compressed
Easy way to figure out how to organize the different pieces of cUrl query to Volley Request is by first running this cUrl query in Post Man and intercept request object in Charles Proxy - Ref : Simulate a specific CURL in PostMan
In my case -
-H values were added as Header items
--data values are added as body
Content-Type set as application/x-www-form-urlencoded

parse getInBackground throws InvalidKeyName exception

I am trying to migrate my Parse app to MongoDB. I have got MangoDB up up and running and connected to pars.com server as described in parse.com/docs/server/guide#migrating.
Now I am trying to connect to my Parse server from Android Parse SDK version is 1.13.0.
Initialization is:
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("apid")
.clientKey("key")
.server("http ://server:1337")
.enableLocalDataStore()
.build());
GET method works fine from command line:
curl -X GET -H "X-Parse-Application-Id: " -H "X-Parse-Master-Key: " -G http : //serverip:1337/classes/New/EXOIesqEa3 {"objectId":"EXOIesqEa3","Name":"Third","createdAt":"2016-01-31T14:24:18.950Z","
However, it dose not work in Android SDK, as it uses POST instead of GET with body, something like:
curl -X POST -H "key" -H "Content-Type: application/json" -d '{"where":"{\"objectId\":\"iXMRHnQN1a\"}","_method":"GET"}' http://server:1337/classes/GameScore1
Parse server response is InvalidKeyName exception: {"code":105,"error":"invalid key name: 0"}.
Can someone help here to figure out why it returns this InvalidKeyName exception?
Please note that:
curl -X POST -H "X-Parse-Application-key" -H "Content-Type: application/json" -d '{"_method":"GET"}' http://server:1337/classes/GameScore1
works fine.

Getting JSON Exception While connecting GCM through curl

I am getting an error when I make a curl request to GCM server:
JSON_PARSING_ERROR: Unexpected character (m) at position 0
curl request:
curl -i -H "Content-Type: application/json" -H "Authorization: key=AIzaSyAuKLBnVEv_bm4fp88RqKaVm8DClzc"
-X POST -d "message":"Hi I am Developer","registration_ids":"["APA91bGj-wkz4m6tEaFfual2HuRHNAn3CmAE6nRmv5LaOnuWa_6D3AnacqTmSCHXiKvdzINVc_XUGJhrXk0z5hQomdCM_9Nf6QqB-Pf9Q6Tf_DraUZZaUVtDiaRaIStgXsx0zMFqKJHU0q75OGCtq5OSGR11l3mCB5DBtzvl4nFwOws_UuA"]"
https://android.googleapis.com/gcm/send
I don't know anything about GCM API, but I see the error. You don't send the valid JSON string and server can't parse it.
Wrap your data in curly braces. Replace
-d "message":"Hi I am Developer","registration_ids":"["APA91bGj-wkz4m6tEaFfual2HuRHNAn3CmAE6nRmv5LaOnuWa_6D3AnacqTmSCHXiKvdzINVc_XUGJhrXk0z5hQomdCM_9Nf6QqB-Pf9Q6Tf_DraUZZaUVtDiaRaIStgXsx0zMFqKJHU0q75OGCtq5OSGR11l3mCB5DBtzvl4nFwOws_UuA"]"
with
-d '{"message":"Hi I am Developer","registration_ids":"["APA91bGj-wkz4m6tEaFfual2HuRHNAn3CmAE6nRmv5LaOnuWa_6D3AnacqTmSCHXiKvdzINVc_XUGJhrXk0z5hQomdCM_9Nf6QqB-Pf9Q6Tf_DraUZZaUVtDiaRaIStgXsx0zMFqKJHU0q75OGCtq5OSGR11l3mCB5DBtzvl4nFwOws_UuA"]"}'

Apache Cordova Android Push Notification Aerogear Unable To Send

While using
curl -3 -u \
"f07c43a6-bb0a-4bb7-a1eb-a368db272212:e2cf19c3-6636-4712-bbe8-26b7c1ac9c09" \
-v -H "Accept: application/json" -H "Content-type: application/json" \
-X POST -d '{"message": {"alert":"Hello AeroGear", "badge":1}}' \
https://aerogear-html5.rhcloud.com/rest/sender
to push notification
I am getting 401 unauthorised request.Unable to figure out how to authenticate?
Make sure your authorization parameters(through -u) are valid and also make sure you are using the correct credential for the service you are trying to access.
Also, if you are from windows(for linux its ok) then wrap the post parameters with double quotes(") Instead of single(').
-d "{\"message\": {\"alert\":\"Hello AeroGear\", \"badge\":1}}"
Going to this link https://aerogear-html5.rhcloud.com, produces a website not available
Is there a specific tutorial you used to get that curl command?

Categories

Resources