1. Go to this page and download the library: Download robuust/craft-hubspot-forms library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
robuust / craft-hubspot-forms example snippets
return [
// General
'accessToken' => 'YOUR_ACCESS_TOKEN',
];
use robuust\hubspotforms\exceptions\SubmissionValidationException;
use robuust\hubspotforms\Plugin as HubSpotForms;
use yii\web\BadRequestHttpException;
// Inside a POST-only, CSRF-protected controller action. Resolve these IDs from
// the server's configured form, not from an arbitrary submitted target URL.
try {
$response = HubSpotForms::$plugin->getForms()->submit($portalId, $formId, $body);
} catch (SubmissionValidationException $exception) {
// $exception->errors contains messages keyed by field name.
throw new BadRequestHttpException($exception->getMessage(), 0, $exception);
}