I have a .csv
file with a bunch of android tokens. For all of these tokens I want to check if they're still valid. In the end I want a .csv
file with an extra column that's called "valid" which can be either 0 or 1. (0 if it's not, 1 if it is).
I want to check each of the tokens by the following command:
curl --header "Authorization: key=[my API key]" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"[my token]\"]}"
If the response is
{
"multicast_id":[
id
],
"success":0,
"failure":1,
"canonical_ids":0,
"results":[
{
"error":"InvalidRegistration"
}
]
}
the token is invalid and I want the column "valid" to be set to 0.
How can I set up a script that automatically checks each token in the .csv
separately and updates the column 'valid' with the right value?