开发者

Sending a message to C2DM keeps returning 401

I have been trying this for two days already with no success. My goal is to send a short message to the C2DM. I have used a s开发者_如何学编程imple Java application and curl, but it keeps returning response code 401: (Unauthorized).

The first curl command:

curl https://www.google.com/accounts/ClientLogin -d Email=firstname.lastname@gmail.com -d Passwd=mypasswd -d accountType=HOSTED_OR_GOOGLE -d source=Google-cURL-Example -d service=ac2dm

returns three long strings: SID, LSID and Auth.

Next, I copy the Auth string to the following command (AUTH_STRING):

curl --header "Authorization: GoogleLogin auth=AUTH_STRING" "https://android.clients.google.com/c2dm/send" -d registration_id=SOME_REGISTRATION_ID -d "data.message=HelloWorld" -d collapse_key=0 -k

but it always returns response code 401. The registration_id is copied from the Android client app and it should be valid.

What's wrong with this? Any help is appreciated.


Problem solved by using the correct email address and password in the first curl command. Email credentials that were used when signing for ac2dm should be used.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜