/** * Sends the OTP writen by the user in the form to the Latch server to check it * if OK stores the appId and secret in the Latch server. * Receives the accountId from the Latch server and stores it in the Mediwiki DB. * @param OTP sent to the mobile phone of the user and writen by user in the Mediawiki pairing form * @ret 1: pairing OK, -1: pairing error */ public static function doPair($otp) { $toRet = -1; //return value=-1, error during unpairing process $api = new Latch(LatchConfig::appId, LatchConfig::secret); //creation of a Latch API object $response = $api->pair($otp); //send the OTP writen by the user in the textbox $data = $response->getData(); //echo( $data->accountId ); if (!is_null($data) && property_exists($data, "accountId")) { $accountId = $data->accountId; dbHelper::storeAccountId($accountId); $toRet = 1; //return value=1, pairing process successful } return $toRet; }