I am trying to submit the inputs of a gravity form on my api but when submitting the form no action is performed. Can i have some help please
my code is :
After taking a look at your code, it seems like the problem might be with the hook you’re using. Instead of using ‘gform_after_submission_87’, which only works for a specific form with ID 87, try using ‘gform_after_submission’ instead.
Additionally, double-check that the lib\Keyyo\Manager\Client class is included in your code and that the access token you’re using is valid. If the access token is invalid, the API won’t be able to authenticate your request and won’t perform any action.
Here’s the updated code with these changes:
add_action( 'gform_after_submission', 'post_to_keyyo', 10, 2);
function post_to_keyyo($entry, $form){
$client_id = "63e609650e960";
$keyyo_authorize_endpoint = "https://ssl.keyyo.com/oauth2/authorize.php";
$access_token = "Hc3RboIwGAXgd/mvuSh0Vro71ojDaTdmnKIYU7BKVWBrqRqWvfsa785JvpPzC3vRCXiGTQ4ES4IoGSBJCcrBywFTjHH4iAd7uexEWUpjXPfJMAyG2CfIw6FbIC9wprSma2upHWgc34IHRh0b0Vkt3cVslLEkZZ+9/6Sjb6YYf2tVciqv91Xa23hCfFnZoF4kPf/QN7xUUVJFE0WL159mrcy0up3Y/SsrWlrXIotf+Hh0HhRpzLvD+57PNfz9Aw==";
try {
// Instantiate a Manager client (version 1.0 here)
require_once '/path/to/lib/Keyyo/Manager/Client.php'; // replace with actual path to the Client.php file
$keyyo_manager = new lib\Keyyo\Manager\Client('1.0', $access_token);
$branches= $keyyo_manager->directory_branches();
// Add contact after form submission
$new_contact = $keyyo_manager->directory_branches('0d31c12d1726dffbb14132b3c0f6dc26')->contacts()->create(array(
"first_name" => $entry[9],
"name" => $entry[8],
"email" => $entry[10],
"mobile_number" => $entry[80]
));
//var_dump($new_contact);
} catch (lib\Keyyo\Manager\Exception\Exception $e){
echo 'Error: ', $e->getMessage();
}
}
Make sure to replace ‘/path/to/lib/Keyyo/Manager/Client.php’ with the actual path to the Client.php file on your server. Let me know if this helps, or if you have any further questions!