0

I used PHP code to write the 3rd servers ,I can get the deviceRegistrationId and authToken, but now I receive "Unauthorized Error 401",here is the PHP code which I used. C2DM implementation PHP code

Community
  • 1
  • 1

2 Answers2

0

Unauthorized Error 401 indicates that the ClientLogin AUTH_TOKEN used to validate the sender is invalid. Please make sure you are sending the correct ClientLogin to the google server.

rfsk2010
  • 8,571
  • 4
  • 32
  • 46
  • I send the email and the pwd to get TOKEN ,are the Email and the Pwd that I submited from the C2DM sign up page? And Source&Service where I get? Here is my PHP code : curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin"); $post_fields = "accountType=" . urlencode('HOSTED_OR_GOOGLE') . "&Email=" . urlencode($username) . "&Passwd=" . urlencode($password) . "&source=" . urlencode($source) . "&service=" . urlencode($service); – user1120915 Dec 30 '11 at 06:15
0

Any client goes through the following cycle:

  1. Obtain an IP address from the IP name of the site (the site URL without the leading
    'http://'). This lookup (conversion of IP name to IP address) is provided by domain name servers (DNSs).
  2. Open an IP socket connection to that IP address.
  3. Write an HTTP data stream through that socket.
  4. Receive an HTTP data stream back from the Web server in response. This data stream contains status codes whose values are determined by the HTTP protocol. Parse this data stream for status codes and other useful information.
  5. This error occurs in the final step above when the client receives an HTTP status code it recognises as '401'.
Maulik J
  • 2,745
  • 19
  • 22