safan-lab/google

Safan module for Google Services

1.0.0 2015-08-29 11:09 UTC

This package is not auto-updated.

Last update: 2024-04-17 07:43:55 UTC


README

REQUIREMENTS

PHP > 5.4.0

SETUP

If you're using Composer for your project's dependencies, add the following to your "composer.json":

"require": {
    "safan-lab/google": "1.*"
}

Update Modules Config List - safan-framework-standard/application/Settings/modules.config.php

<?php
return [
    ...
    'Google' => 'vendor/safan-lab/google/Google'
    ...
];

Captcha

Add new config file with name - safan-framework-standard/application/Settings/google.config.php Official documentation - Google reCaptcha

<?php
return [
    'captcha' => [
        'siteKey'   => 'your_site_key',
        'secretKey' => 'your_secret_key'
    ]
];

For rendering captcha you can use Safan Object Manager

<?= \Safan\Safan::handler()->getObjectManager()->getInstance('Google\Google')->getService('captcha')->render() ?>

For checking data

<?php
    // get post data
    $captchaField = \Safan\GlobalData\Post::str('g-recaptcha-response');
    // check data
    $googleCaptchaService = \Safan\Safan::handler()->getObjectManager()->getInstance('Google\Google')->getService('captcha');
    $response = $googleCaptchaService->check($captchaField);

    if($response['status'] === false)
        return $response['message'];
?>