No coder's blog is complete without a code sample so without further ado here it comes.
On my current project we're using OpenID. When folk come to register we wanted to be cool and prepopulate the fields on our reg. form with data from your OpenID persona (Name, Email, Nickname etc). After a bit of googling and hackery I figured the way to do this is to use a simple extension of the OpenID persona stuff called SReg (simple registration extension). You can request extra user data by calling the following on the response object.
response = openid_consumer.begin openid_server_url
response.add_extension_arg('sreg','required','email,nickname')
response.add_extension_arg('sreg','optional','gender')
response.redirect_url(return_to_url, complete_openid_signon_url)
When your latest victim gets redirected to their OpenID server, they will be prompted to allow your site access to the specific details you ask for.
Enjoy!










0 comments:
Post a Comment