this mail was sent to play thru. Could U help ?

More
24 Aug 2012 16:26 #60 by all
Hi. Nice plugin for my joomla2.5 BUT, when everything done I get a "For security reasons, you must pass the a secret variable to PlayThru servers" message. Need some help.
Same suggestion as Lionel. I'm (so sorry) French.

Let my people know about U using French language ;)

Please Log in to join the conversation.

More
03 Sep 2012 10:00 #119 by admin
sorry for the delay, but i didnt' get the notification for this topic.

Did you register to the areyouhuman site and get your keys?
I'm sorry but i didn't understand the part about the language, can you explain better?

Please Log in to join the conversation.

More
10 Feb 2013 04:47 - 10 Feb 2013 04:48 #625 by felfert
Hi,

I don't speak french, but - regarding the error message - maybe, I can help here too....

When developing my code snippet for K2, I had the same error which apparently happens, if your plugin class is instantiated more than once. It only went away, when I added the correct namespace value (see my pinned snippet). By using the same namespace like Joomlas's core, I made shure, that only one instance is used. Apparently, areyouahuman.com only checks for a secret, if more than one session is established. This brings me to the conclusion, that an essential part of initialization is missing in your plugin. I analyzed your code and compared it against parts of the WordPress plugin found here . If you compare your onDisplay() method with the getPublisherHTML() method of the Wordpress plugin, you can see, that they perform an additional step before generating the embedding HTML:

Before generating the embedding HTML, they perform a JSON request to

ws.areyouahuman.com/ws/setruntimeoptions/<publisher_key>

and fetch the session_secret from the response.
Therefore, if converted to Joomla code, your onDisplay() should look like this:
$fields = array('config' => array()); // empty options for now, maybe configurable gameid later.
$resp = $this->doHttpsPostReturnJSONArray(self::AYAH_WEB_SERVICE_HOST, "/ws/setruntimeoptions".urlencode($this->ayah_publisher_key), $fields);
if ($resp) {
    $this->session_secret = $resp->session_secret;
    $url = 'https://' . self::AYAH_WEB_SERVICE_HOST . "/ws/script/".urlencode($this->ayah_publisher_key);
    $url .= (empty($this->session_secret))? "" : "/".$this->session_secret;
    return "<div id='AYAH'></div><script src='". $url ."' type='text/javascript'></script>";
} else {
    throw new Exception(JText::_('PLG_PLAYTHRU_ERROR_SERVICE_UNAVAILABLE'));
}

Of course, you also would have to add PLG_PLAYTHRU_ERROR_SERVICE_UNAVAILABLE to your translations...

DISCLAIMER: This code is completely untested - will try it out next week...

-Fritz
Last edit: 10 Feb 2013 04:48 by felfert.

Please Log in to join the conversation.

More
10 Feb 2013 09:32 #626 by admin
thank you very much.
however, why should you instantiate the plugin more than once?
Do you have more than one form on your page?

Please Log in to join the conversation.

More
10 Feb 2013 15:51 - 10 Feb 2013 16:06 #627 by felfert
Yes. The actual registration is using K2's override, but the "Forgot password" and "Forgot username" forms are not overwritten by K2, so they are using the core forms.

The instantiation is implicitely done by Joomla's factory, when calling
$jcaptcha = JCaptcha::getInstance('playthru', array('namespace' => 'xyz'));
Joomla's core user component uses their form namespace "com_users.registration" and Joomla's default behavior of the captcha input element is to use its form name. So it's very likely, that if somebody uses Joomla's capcha element in another component xml, a different namespace is used resulting in another instance. I only got around it by forcing the namespace to com_users.registration programmatically (which is wrong and should not be necessary).

My guess is, that the french guy runs exactly in this scencario. He most likely has some additional component installed, which uses Joomla's captcha framework.

-Fritz
Last edit: 10 Feb 2013 16:06 by felfert.

Please Log in to join the conversation.

Time to create page: 0.420 seconds