Revisions for "need help implementing google recaptcha in Laravel app/w vue.js"

need help implementing google recaptcha in Laravel app/w vue.js

I'm trying to implement google recaptcha in a Laravel app. I basically followed these instructions https://m.dotdev.co/google-recaptcha-integration-with-laravel-ad0f30b52d7d.

My form is sent through Ajax/vue.js (in a component) so in my blade file, I pass my recaptcha public key to my component, like this: <contact :lang="'{{ app()->getLocale() }}'" :grecaptcha="'{{ env('GOOGLE_RECAPTCHA_KEY') }}'"></contact> and I catch it as a prop in my vue component. Then I have these lines in my component: <div class="g-recaptcha"
:data-sitekey="grecaptcha"
data-callback="onSubmit"
data-size="invisible">
</div>
which submits to my EmailController@emailAdmin where I have an EmailRequest. In that EmailRequest I have this under rules: 'g-recaptcha-response'=>'required|recaptcha' which call a method I have registered in AppServiceProvider: public function boot()
{
Validator::extend(
'recaptcha',
'App\Validators\ReCaptcha@validate'
);
}

This is the Recaptcha@validate function:

`public function validate()
{
$client = new Client();
$gRecaptchaResponse = Input::get('g-recaptcha-response');

    $response = $client->post('https://www.google.com/recaptcha/api/siteverify',
        ['form_params' =>
            [
                'secret' => env('GOOGLE_RECAPTCHA_SECRET'),
                'response' => $gRecaptchaResponse
            ]
        ]
    );
    $body = json_decode((string)$response->getBody());
    dd($body);
    return $body->success;
}`

Somehow the dd($body) returns me {#232
+"success": false
+"error-codes": array:1 [
0 => "invalid-input-response"
]
}
`

I can't figure out why I have an invalid-input-response.

I'm willing to send you the project. Let me know if you think you can help. I'm willing to tip extras.

need help implementing google recaptcha in Laravel app/w vue.js
I'm trying to implement google recaptcha in a Laravel app. I basically followed these instructions https://m.dotdev.co/google-recaptcha-integration-with-laravel-ad0f30b52d7d. My form is sent through Ajax/vue.js (in a component) so in my blade file, I pass my recaptcha public key to my component, like this: `` and I catch it as a prop in my vue component. Then I have these lines in my component: ```
``` which submits to my EmailController@emailAdmin where I have an EmailRequest. In that EmailRequest I have this under rules: `'g-recaptcha-response'=>'required|recaptcha'` which call a method I have registered in AppServiceProvider: ```public function boot() { Validator::extend( 'recaptcha', 'App\Validators\ReCaptcha@validate' ); }``` This is the Recaptcha@validate function: `public function validate() { $client = new Client(); $gRecaptchaResponse = Input::get('g-recaptcha-response'); $response = $client->post('https://www.google.com/recaptcha/api/siteverify', ['form_params' => [ 'secret' => env('GOOGLE_RECAPTCHA_SECRET'), 'response' => $gRecaptchaResponse ] ] ); $body = json_decode((string)$response->getBody()); dd($body); return $body->success; }` Somehow the dd($body) returns me `{#232 +"success": false +"error-codes": array:1 [ 0 => "invalid-input-response" ] }`` I can't figure out why I have an invalid-input-response. You can find the project here https://bitbucket.org/danygiguere/nuvoweb You will have to run npm install, composer install, copy the .env, run php artisan key:generate and add your own recaptcha keys. Let me know if you think you can help. I'm willing to send you the project. Let me know if you think you can help. I'm willing to tip extras.
need help implementing google recaptcha in Laravel app/w vue.js
I'm trying to implement google recaptcha in a Laravel app. I basically followed these instructions https://m.dotdev.co/google-recaptcha-integration-with-laravel-ad0f30b52d7d. My form is sent through Ajax/vue.js (in a component) so in my blade file, I pass my recaptcha public key to my component, like this: `` and I catch it as a prop in my vue component. Then I have these lines in my component: ```
``` which submits to my EmailController@emailAdmin where I have an EmailRequest. In that EmailRequest I have this under rules: `'g-recaptcha-response'=>'required|recaptcha'` which call a method I have registered in AppServiceProvider: ```public function boot() { Validator::extend( 'recaptcha', 'App\Validators\ReCaptcha@validate' ); }``` This is the Recaptcha@validate function: `public function validate() { $client = new Client(); $gRecaptchaResponse = Input::get('g-recaptcha-response'); $response = $client->post('https://www.google.com/recaptcha/api/siteverify', ['form_params' => [ 'secret' => env('GOOGLE_RECAPTCHA_SECRET'), 'response' => $gRecaptchaResponse ] ] ); $body = json_decode((string)$response->getBody()); dd($body); return $body->success; }` Somehow the dd($body) returns me `{#232 +"success": false +"error-codes": array:1 [ 0 => "invalid-input-response" ] }`` I can't figure out why I have an invalid-input-response. You can find the project here https://bitbucket.org/danygiguere/nuvoweb You will have to run npm install, composer install, copy the .env, run php artisan key:generate and add your own recaptcha keys. Let me know if you think you can help. I'm willing to tip extras.
Back to question