views:

126

answers:

3

Hello everybody,

Below is a working example of my OpenId implementation. I use hyves.nl as the OpenId provider but this also works with me.yahoo.com and probably other OpenId providers as well (but not Google).

So far so good. But now I want to fetch the nickname and/or fullname from my hyves profile. But when I set nickname and/or fullname to true in the $props array I can't login anymore at all.

What am I doing wrong here?

class TestController extends Zend_Controller_Action
{
    private $_sreg = null;

    public function init()
    {
        $props = array('nickname' => false, 
        'email' => false, 
        'fullname' => false, 
        'dob' => false, 
        'gender' => false, 
        'postcode' => false, 
        'country' => false, 
        'language' => false, 
        'timezone' => false);

        $this->_sreg = new Zend_OpenId_Extension_Sreg($props);
    }

    public function loginAction()
    {
        $consumer = new Zend_OpenId_Consumer();

        if (!$consumer->login('hyves.nl', 'http://localhost/trouwcom/public/test/verify', 'http://localhost/trouwcom', $this->_sreg))
        {
            echo 'Login failed';
        }

        $this->_helper->viewRenderer->setNoRender();
    }

    public function verifyAction()
    {
        $consumer = new Zend_OpenId_Consumer();

        if ($consumer->verify($_GET, $id, $this->_sreg))
        {
            echo 'VALID ' . htmlspecialchars($id);

            $data = $this->_sreg->getProperties();
            print_r($data);
        }

        else
        {
            echo 'INVALID ' . htmlspecialchars($id);
        }

        $this->_helper->viewRenderer->setNoRender();
    }
}
A: 

Could it be this bug? http://framework.zend.com/issues/browse/ZF-5266

Anti Veeranna
Just checked my profile. It's completely filled in.
Erik
BTW when using the fixed code from the link I no longer get the INVALID error. But the $this->_sreg->getProperties() array is just keys with no assigned values.
Erik
A: 

Don't know if you find your answer already. But if you didn't or anyone else is reading this question like me and having the same problem I just found the answer.

The problem with openId provider "hyves.nl" is that they don't return the verification parameters by $_GET but by $_POST.

# This works    
$consumer->verify($_POST, $id, $this->_sreg);
Yo-han
A: 

I am getting the same result ($this->_sreg->getProperties() array is just keys with no assigned values.) with Gmail.

Ravi