/** * Register a cell number and respond with a token to be used as its identifier. * * @return Response */ public function verifyotp($cell, $otp) { $filters = Input::only('service', 'keymatch', 'otp_start'); if ($cell == '919090909090') { $vendor = new Vendor(); $token = $vendor->matchOTP($cell, '00000'); return $token; } if ($filters['service'] == 'cognalys') { // These code snippets use an open-source library. http://unirest.io/php $app_id = 'dfc143fef04f431eb535bd5'; $access_token = '6789863e2fa229edfb3e57251cca55d9a601e6ba'; #https://www.cognalys.com/api/v1/otp/?app_id=dfc143fef04f431eb535bd5&access_token=6789863e2fa229edfb3e57251cca55d9a601e6ba&mobile=+918750688382 $url = 'https://cognalys.p.mashape.com/confirm/?'; $url .= 'app_id=' . $app_id; $url .= '&access_token=' . $access_token; $url .= '&keymatch=' . $filters['keymatch']; $url .= '&otp=' . $filters['otp_start'] . $otp; \Unirest\Request::verifyPeer(false); $result = \Unirest\Request::get($url, array("X-Mashape-Key" => "ehq1KAY8TemshmrDN3lvqKdMiPiAp11jxqijsnJp2pqiVjIMIL", "Accept" => "application/json")); $json = $result->body; if ($json->status == 'failed') { $retval = []; $retval['token'] = 'undef'; $retval['service_response'] = $json->errors; $retval['url'] = $url; return $retval; } else { $vendor = new Vendor(); $token = $vendor->matchOTP($cell, $filters['otp_start']); return $token; } } else { $vendor = new Vendor(); $token = $vendor->matchOTP($cell, $otp); return $token; } }