Gcm Implementation Using Php Always Facing Unauthorized Error 401
Solution 1:
I battled same problem. Turned out it was IPv6 related! I created server key as described in http://developer.android.com/google/gcm/gs.html using 0.0.0.0/0 as permitted host IP, but that does not match IPv6. So I added another permitted host line IP as 0::0/0 and that worked (AFTER some time, to update cached config?).
Leaving the IP field blank allows ANY IP and is easier.
Solution 2:
I can see several errors:
Contenttype:application/json
should beContent-Type: application/json
.- You forgot to include the registration ids in the JSON.
- I'm not sure if
CURLOPT_SSL_VERIFYPEER => false
andCURLOPT_SSL_VERIFYHOST => false
are required.
You can find many PHP GCM samples that work (for example - here).
Solution 3:
This is due to you are not enable you IP to access GCM,To Know your network IP type "my ip" in GOOGLE,after that create SERVER KEY in you Google_Api_Console and Use the ip in SERVER KEY generation,Use the SERVER KEY in your php file in local server,the first image show's the list of key in google console to select,choose server key and second image show's that to put the ip what you need to enable.
Post a Comment for "Gcm Implementation Using Php Always Facing Unauthorized Error 401"