forked from miguel456/rbrecruiter
Switch custom Guzzle integration for Laravel's HTTP facade
Commit also adds config options to the example file.
This commit is contained in:
parent
623200914d
commit
7cf056f57e
|
@ -13,6 +13,11 @@ DB_DATABASE=laravel
|
|||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
RECAPTCHA_SITE_KEY=
|
||||
RECAPTCHA_PRIVATE_KEY=
|
||||
RECAPTCHA_VERIFY_URL="https://www.google.com/recaptcha/api/siteverify"
|
||||
# WARNING: Your contact form will be useless if you change this value. Only change this URL if Google updates it.
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_CONNECTION=sync
|
||||
|
|
|
@ -4,15 +4,13 @@ namespace App\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use GuzzleHttp;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
|
||||
public function create(Request $request)
|
||||
{
|
||||
// TODO: use service provider instead
|
||||
$client = new GuzzleHttp\Client();
|
||||
|
||||
$name = $request->name;
|
||||
$email = $request->email;
|
||||
$subject = $request->subject;
|
||||
|
@ -20,13 +18,12 @@ class ContactController extends Controller
|
|||
|
||||
$challenge = $request->input('captcha');
|
||||
|
||||
$verifyrequest = $client->request('POST', config('recaptcha.verify.apiurl'), [
|
||||
'form_params' => [
|
||||
'secret' => config('recaptcha.keys.secret'),
|
||||
'response' => $challenge,
|
||||
'remoteip' => $_SERVER['REMOTE_ADDR']
|
||||
]
|
||||
$verifyrequest = Http::asForm()->post(config('recaptcha.verify.apiurl'), [
|
||||
'secret' => config('recaptcha.keys.secret'),
|
||||
'response' => $challenge,
|
||||
'remoteip' => $_SERVER['REMOTE_ADDR']
|
||||
]);
|
||||
|
||||
$response = json_decode($verifyrequest->getBody(), true);
|
||||
|
||||
if (!$response['success'])
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue