Reputation: 55
I have an app in adalo.com which calls my custom api (simple PHP file) api.domain.com. When it is called, there are two requests to jotform.com.
First is GET and works nicely. And second is POST.
When I tried the POST request on localhost with custom data, it works. It also work when I try POST request via https://reqbin.com/.
So the problem is, as it seems, when Adalo app calls my API after I submit form.
Everything works just not the POST request (e.g. I got all data from Adalo form in the log file and GET request to Jotform works).
Below the code of function.
function post_data( $path, $post_data = array() ) {
if( empty( $path ) || empty( $post_data ) ) return false;
$api_url = JOTFORM_API_URL;
$api_key = JOTFORM_API_KEY;
$post_data_url = implode( '&', $post_data );
// error_log( 'post_data' );
// error_log( $post_data_url );
$url = "{$api_url}{$path}?apikey={$api_key}&{$post_data_url}";
// error_log( 'url' );
// error_log( $url );
// echo $url . "\n\n";
// return;
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_USERAGENT, 'JOTFORM_PHP_WRAPPER');
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $curl, CURLOPT_POST, true);
$exec = curl_exec( $curl );
if ( $exec === false ) {
error_log( curl_error( $curl ) );
}
$data = json_decode( $exec, true );
curl_close( $curl );
error_log( var_dump( $data ) );
return $data;
}
Upvotes: 0
Views: 83