s"; $API['VERSION'] = "1.03"; if(isset($_REQUEST['startTrial'])) { $arrArgs['user_name'] = $_REQUEST['user_name']; $arrArgs['user_mobile'] = $_REQUEST['user_mobile']; foreach($_REQUEST['friend_name'] as $key => $value) { $arrArgs['friend_name['.$key.']'] = $value; } foreach($_REQUEST['friend_mobile'] as $key => $value) { $arrArgs['friend_mobile['.$key.']'] = $value; } $arrArgs['message'] = $_REQUEST['message']; $arrArgs['method'] = "3jam.trial.startNew"; $result = send_to_server($arrArgs); if(preg_match("//",$result)) { //Start 3jam trial request successful. Now display captcha preg_match("//",$result)) { //Captcha verification successful. Mobile verification code sent, now ask user to input it. display_mobile_verification($_REQUEST['conversation_id']); } else { //Error found so re-display form and error preg_match("/msg=\"(.*)\"/",$result,$matches); $sErrorMsg = $matches[1]; display_captcha($_REQUEST['conversation_id'],$sErrorMsg); } } else if(isset($_REQUEST['submitMobileVerification'])) { $arrArgs['conversation_id'] = $_REQUEST['conversation_id']; $arrArgs['verification_code'] = $_REQUEST['verification_code']; $arrArgs['method'] = "3jam.trial.confirmTrial"; $result = send_to_server($arrArgs); if(preg_match("//",$result)) { //Submit mobile verification code successful display_3jam_started(); } else { //Error found so re-display form and error preg_match("/msg=\"(.*)\"/",$result,$matches); $sErrorMsg = $matches[1]; display_mobile_verification($_REQUEST['conversation_id'],$sErrorMsg); } } else { display_form(); } function send_to_server($arrArgs) { global $API; //Set API Version number $arrArgs['api_version'] = $API['VERSION']; //Set API URL $url = "https://api.3jam.com/webapi.php"; //Set authentication keys $arrArgs['api_key'] = $API['KEY']; $creq = curl_init(); curl_setopt($creq, CURLOPT_URL, $url); curl_setopt($creq, CURLOPT_TIMEOUT, 20); //set timeout in case other side hangs, which won't return for a while curl_setopt($creq, CURLOPT_RETURNTRANSFER, 1); curl_setopt($creq, CURLOPT_POST,1); curl_setopt($creq, CURLOPT_POSTFIELDS, $arrArgs); curl_setopt($creq, CURLOPT_SSL_VERIFYPEER, FALSE); //Turn off certificate verification so Curl works $curl_result = curl_exec($creq); if(curl_errno($creq)) { //If there's a problem with Curl on your machine print "Curl error on local machine: ".curl_error($creq); } return $curl_result; } function display_form($sErrorMsg='') { $html = '

Discuss with friends!

'.($sErrorMsg == '' ? '' : ''.$sErrorMsg.'').' '; print $html; } function display_captcha($conversation_id,$sErrorMsg='') { $html = '

Please type in the text you see below

'.($sErrorMsg == '' ? '' : ''.$sErrorMsg.'').'



'; print $html; } function display_mobile_verification($conversation_id,$sErrorMsg='') { $html = '

Please enter the verification code sent to your mobile phone

'.($sErrorMsg == '' ? '' : ''.$sErrorMsg.'').'

'; print $html; } function display_3jam_started() { $html = '

3jam started!

Click here to start another.'; print $html; } ?>
Your name:
(eg Joe Brown)
Your mobile number:
(eg 12125558888)
Friend 1:Friend 1 number:
Friend 2:Friend 2 number:
Friend 3:Friend 3 number:
Friend 4:Friend 4 number:
Friend 5:Friend 5 number:
Message: