# Gravity form submission

**URL:** https://community.gravityforms.com/t/gravity-form-submission/14650
**Category:** Get Help
**Tags:** custom, gform\_after\_submission
**Created:** [March 8, 2023, 11:17am UTC](https://community.gravityforms.com/t/gravity-form-submission/14650 "2023-03-08T11:17:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![picard](https://avatars.discourse-cdn.com/v4/letter/p/ee59a6/32.png) [@picard](https://community.gravityforms.com/u/picard)
#### Post date: [March 8, 2023, 11:17am UTC](https://community.gravityforms.com/t/gravity-form-submission/14650/1 "2023-03-08T11:17:55Z")

</div>

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 :

```auto
add_action( 'gform_after_submission_87', '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)
        $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(); 
}
}
// ***********************api keyyo**************** api keyyo ********************api keyyo*********************

```

---

<div class="post-metadata">

### Author: ![faisalahammad](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/faisalahammad/32/13948_2.png) [@faisalahammad](https://community.gravityforms.com/u/faisalahammad)
#### Post date: [March 10, 2023, 6:51am UTC](https://community.gravityforms.com/t/gravity-form-submission/14650/2 "2023-03-10T06:51:52Z")

</div>

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:**

```auto
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!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)
#### Post date: [April 9, 2023, 6:52am UTC](https://community.gravityforms.com/t/gravity-form-submission/14650/3 "2023-04-09T06:52:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
