views:

121

answers:

1

Hi,

I am very new to the OpenID logic, so please excuse me if I am asking something trivial. I am using the OpenID component for CakePHP by Cakebaker, with the PHP OpenID library by JanRain.

It's all working quite well, but I could not find an exhaustive way to retrieve user informations depending on provider and method (sreg vs. ax). So this is what I came up with:

if ($axResponse) {
    if (is_array($a = $axResponse->get('http://axschema.org/contact/email'))) {
        $user_record['email'] = $a[0];
        if (is_array($b = $axResponse->get('http://axschema.org/namePerson'))) {
            $user_record['nickname'] = $b[0];
        }
    } else if (is_array($a = $axResponse->get('http://schema.openid.net/contact/email'))) {
        $user_record['email'] = $a[0];
        if (is_array($b = $axResponse->get('http://schema.openid.net/namePerson'))) {
            $user_record['nickname'] = $b[0];
        }
    }
} else if ($sreg) {
    if (isset($sreg['email'])) {
        $user_record['email'] = $sreg['email'];
    }
    if (isset($sreg['nickname'])) {
        $user_record['nickname'] = $sreg['nickname'];
    }
}

Although I tested it successfully with Google, Yahoo! and AOL's OpenID, I'm sure I would run into trouble with other / smaller providers. Is there a better and nicer way to achieve the same result? This seems particularly flawed if I try to fetch other optional fields...

Thanks for your input and suggestions!

+1  A: 

Well I am sorry... i don't know much about the "OpenID component for CakePHP", but i have worked with the lightopenid and it is opensource also..

Check this out: http://code.google.com/p/lightopenid/updates/list

I have worked with this many times.. and it is good.. I hope this helps...

Chetan sharma
Unfortunately this doesn't help me much, as everything already works fine. I'm more looking for an elegant way to deal with the response, which isn't covered by this library and its documentation either...
Damien
No problem, Daniem, It was just and idea, thanks for the feedback...
Chetan sharma
Theoretically, you could just copy the `get*Attributes()` functions from LightOpenID, substituting `$this->data` -> `$_GET + $_POST`.
Mewp
I have to say this looks like a fine Library, but I wish I could keep mine as it already cost me some time. Also, I find it weird that you achieve so much with so much less code than the JanRain library!
Damien