I have 2 sites.
- Sita A runs Wordpress and has Gravity Forms.
- Site B is attempting to use the Gravity Forms Web API to add an entry to Gravity Forms in Site A
Regardless of what I try, the best result I can get is a "resource created" response (201) with an empty response object. Regardless of the success response, no record is created.
{"status":201,"response":[]}
I can successfully GET data so I don't think it's an auth issue. The documentation says the response should contain "A localized message describing the result: "Entries created successfully"".
I've tried pointing at /entries as well as /forms/$form_id/entries
I installed the Web API Client plugin and successfully created a record with that. I've also poured over that code a thousand times. That plugin uses wp_remote_request to post the data which I can't use because I'm not running Wordpress.
Here's the current code:
<?php
$api_key = '123';
$private_key = 'abc';
$method = 'POST';
$endpoint = 'http://example.com/gravityformsapi/';
$route = 'entries';
//$route = 'forms/17/entries';
$expires = strtotime('+60 mins');
$string_to_sign = sprintf('%s:%s:%s:%s', $api_key, $method, $route, $expires);
$sig = calculate_signature($string_to_sign, $private_key);
$api_call = $endpoint.$route.'?api_key='.$api_key.'&signature='.$sig.'&expires='.$expires;
$data = array(
"id" => "",
"date_created" => "",
"form_id" => "17",
"1" => "[email protected]"
);
$ch = curl_init($api_call);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
print_r($result);