Note: Before you spend your time reading on, please know that C2DM is itself deprecated now and replaced by GCM (http://developer.android.com/guide/google/gcm/c2dm.html)
-- Original question --
Do we have example code for implementing PHP server-side code to push messages to Android devices using C2DM?
I have searched for many code samples which are using old authentication method ClientLogin which is deprecated. Reference: https://developers.google.com/accounts/docs/AuthForInstalledApps (Important: ClientLogin has been officially deprecated as of April 20, 2012. It will continue to work as per our deprecation policy, but we encourage you to migrate to OAuth 2.0 as soon as possible.)
Here
you can take a look, it worked for me.
You need to get your device registrationId,and enter your c2dm account email address and password to post.php.
And the other thing that you need to know is about c2dm.php, there is an error occurs when it tries to check out server response as "200 OK". Because it is trying to get this response from the body. Just simply comment the line in it, then run.
That does not apply with C2DM since is a hosted accountif you see the https://developers.google.com/accounts/docs/AuthForInstalledApps it saids
Also, if you see the graphic is a clear interaction between User as a UI interface since a CAPTCHA is involved.
Edit
BTW you can see from this post C2DM mechanism still will be using ClientLogin nevertheless the key before October 2011 were going to expired, so you need to recreate them. This is a pretty recent post from 8 days before the ClientLogin was deprecated. C2DM Client Login Key
I couldn't figure out how to use C2DM with oAuth 2.0 yet but here's what I've tried. Hope this can help someone to solve similar problem
I found a resource that would be useful at http://aleksmaus.blogspot.com/2012/01/oauth2-with-google-c2dm-push.html But when I tried to send message with C2DM through OAuth 2.0 it didn't work while did a good job with ClientLogin.
This is how I did with console and web browser (I know, you've asked PHP implementation. But I hope this can also be helpful for you)
Client Login: (Succeeded)
got auth token from:
And sent C2DM message like this:
Then my application successfully received C2DM message
oAuth 2.0: (Failed)
got an oAuth 2.0 auth credential from web browser by accessing url:
(Google API Console: https://code.google.com/apis/console/ )
And sent like this:
Then got 401 error response :(
Is there anybody who can point out what I've done something wrong?
Edit
I've found the sentence "AC2DM is currently an API in Labs" in the mail that you might received from Google when register C2DM. And ClientLogin deprecation policy will not apply to versions, features, and functionality labeled as "experimental." I'm not sure but I think this is why our codes didn't work.
Of course, I hope ClientLogin also be deprecated and replaced with OAuth 2.0 soon