PHP code example of epicformbuilder / wixhive-php-api
1. Go to this page and download the library: Download epicformbuilder/wixhive-php-api 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/ */
epicformbuilder / wixhive-php-api example snippets
// create WixHive object
$wixHive = new WixHive("{app_id}", "{app_secret_key}");
// generate data for activity
$field = new \stdClass();
$field->name = "Name";
$field->value = "Value";
$activityInfo = new \stdClass();
$activityInfo->fields = [$field];
// create the model
$createActivity = new CreateActivity(
new DateTime(),
ActivityType::CONTACT_CONTACT_FORM,
null,
null,
$activityInfo,
);
// create the command to execute
$command = new CreateContactActivity($createActivity);
try{
/** @var ActivityResult $data */
$data = $wixHive->execute($command, "{instance_id}" $userSessionToken); // <-- $userSessionToken comes from Wix JS SDK
}catch (WixHiveException $e){
// catch an error here
print_r($e->getMessage());
}
// check what we got
print_r($data);
exit;