views:

214

answers:

3

I've been trying to get a simple OpenId log-in working using first php-openId (Jain) and then the ZendFramework, and in both cases I run up against a similar problem. I'm using the example Zend code from step 38.2.2 of http://framework.zend.com/manual/en/zend.openid.consumer.html.

I see the log-in page fine, but when I enter my openId, this code executes: if (isset($_POST['openid_action']) && $_POST['openid_action'] == "login" && !empty($_POST['openid_identifier'])) {

    echo "New consumer";
    $consumer = new Zend_OpenId_Consumer();
    echo "Gotim";

    if (!$consumer->login($_POST['openid_identifier'])) {
        $status = "OpenID login failed.";
        echo "Failure";
    }
    echo "Continuing";

The code seemingly hangs on the function call to $consumer->login. I see the output from my first two echos, but I never see either Failure or Continuing (and without the echos I just get a 500 Server Internal Error when I try to log-in). If I enter an invalid openId then I get the correct "OpenID login failed." error message.

I apologize if I'm being a moron here. I'm a former programmer who got promoted to management, and I'm trying to get back into it - but I'm using a bunch of technologies that are new to me (PHP, OpenID, Zend Framework), and this just isn't making any sense right now.

Does anyone have any ideas where to look? I can't believe that the Framework itself is bugged (especially not when I had a similar problem with the Jain openId stuff also). I'm using fatcow.com for web hosting - not sure if that's relevant.

A: 

I still don't really understand what's wrong, but I tried running the same code on a different web host (x10hosting.com) and my sample code worked immediately. Therefore I have to conclude that this is some kind of limitation of the Fatcow webhosting service, which is rather a shame. I guess I'll be changing hosts.

papagen0
I'd play around with different `Zend_Http_Client` (which the OpenID Consumer class uses internally) adapters, to see if you have any more luck with them. See my answer http://stackoverflow.com/questions/1183276/1201864#1201864
jason
A: 

If you are getting a 500 error, there is definitely a more detailed message in the web server logs. If your server is running apache, then it is most likely under /usr/local/apache/logs/error_log or /etc/httpd/logs/error_log or something similar. I am assuming you are on a shared hosting plan, so you won't have access to these. You should contact your webhosting company, as they will be able to look through the logs for you.

Mark
+1  A: 

Your code seems to be failing when trying to make the external HTTP connection to the OpenID provider. This could be caused by a number of things, but here's a couple suggestions:

  • Perhaps you're behind a proxy?
  • If not that, maybe your current host does not allow contacting remote servers using sockets (the url_fopen ini directive). The default adapter for Zend_Http_Client is its socket adapter.

So, I would recommend trying is to pass a Zend_Http_Client instance using a different adapter to your Zend_OpenId_Consumer class using the setHttpClient method.

There are a couple different client adapters available:

  • Zend_Http_Client_Adapter_Socket (default)
  • Zend_Http_Client_Adapter_Proxy
  • Zend_Http_Client_Adapter_Test
  • Zend_Http_Client_Adapter_Curl

Try something like this:

 $client = new Zend_Http_Client(null, array(
    'adapter'    => 'Zend_Http_Client_Adapter_Proxy',
    'proxy_host' => 'example.com',
    'proxy_port' => 8000,
    'proxy_user' => 'user',
    'proxy_pass' => 'pass'
));

$consumer = new Zend_OpenId_Consumer();
$consumer->setHttpClient($client);

Your ISP should have documentation about their proxy, if this is in fact the issue. If proxying is not your problem, try the curl adapter and see if you have any more luck.

jason