How to get entry data from gravity form to php file?

Hi. I want to send gravity forms entry data to another API through my php file, I’m using gravity flow to post an “outgoing webhook” to a php file that is on the same server.

Basically, in my php file that I send my webhook to, I have no idea how to retrieve entry data.

I tried

$inputJSON = file_get_contents(‘php://input’);
$input = json_decode($inputJSON, TRUE); //convert JSON into array

like this, but it doesn’t seem to work. Anyone know how can I retrieve entry data from gravity form/flow POST? Thanks.

Hello Rytis. You can access all the Gravity Forms data from the database using our API functions here: https://docs.gravityforms.com/api-functions/

If you are using GravityFlow and have questions about how to use that, please contact GravityFlow support for assistance.

If you have any other questions, please let us know with a small example of how you need to access the data and what you want to do with it. Thank you.

A few suggestions that may fit:

  • Don’t use an outgoing webhook if everything is staying on server. The custom step framework might be more appropriate. Then using something like wp_remote_post to send on to the ‘another API’.
  • You could send the outgoing webhook to a WP Rest API endpoint on the same server that would handle a lot of the authentication/parsing for you.
  • Struggling to see where the reason to call the website via API that already has the data when your end goal is a 3rd party API. Whether from the step settings or filters like gravityflow_webhook_args there is usually enough to support making the 3rd party call via the webhook directly.

As Chris suggested, reaching out to Gravity Flow support with more specifics about your use case will be the fastest way to get the quality support you are looking for.

1 Like

One alternative is to send the browswer to a separate confirmation page that has the entry_id as a url parameter. Then on that page you can use GF functions to pull the data for the entry so that is available to all you programming and calling out other APIs.

It is a simple processed to add the entry_id to the confirmation page.

There should be a way to get the entry_id from a POST vaiable but I have not done that before.

Hi.
I did contact GF Support but didn’t get much help either with outgoing webhook or sending data to same server via webhook.

Problem is: The 3RD Party API I’m using has authentication that I can’t do with GravityFlow outgoing webhook. API Requires for me to send a random 32 symbols code, then it sends back it’s key or whatever which I use in my final API request, none of which I can do with just a normal outgoing webhook from gravity flows.

as Chris mentioned, using GF API:

Yeah, but I just needed this to call my 3rd party API script every time entry reaches certain step in workflow, wasn’t sure how to do it so simplest way was just to have an outgoing webhook to the same server with all the data.

However, I did figure out how to retrieve data from outgoing webhook so it’s all good.

Hey Chris,

Glad you were able to sort out some of your data connectivity challenges. The pattern you describe for the API could likely be handled using 2 workflow steps:

  • First step does the authentication call with the 32 character random value generated via gravityflow_webhook_args. Use the response mapping feature to store the auth into an administrative field on the form.
  • Use that auth field via merge tag in the URL (or request body) of the second step webhook call for your final API request.

While the storage mechanism is different, that pattern is not hugely different from what an oauth approval cycle does. If the auth has a specific duration that you do not need to refresh on every request, storing the token expiration date and token into a WP option and same gravityflow_workflow_args to retrieve from there instead of the added field.

Feel free to reach out to gravityflow.io/support if you need more in-depth assistance.

Cheers,
Jamie