Search code examples
phpwordpressgravity-forms-plugin

Gravity Forms Remote Web API PHP


I'm trying to get data from gravity forms using the Web API on a different website. I so far have this:

<?php
$field_filters = array ( 
                     array( 
                         'key'      => '50', 
                         'operator' => 'is', 
                         'value' => '2020' 
                     ) 
                 );

$search['field_filters'] = $field_filters;

$search_json = urlencode( json_encode( $search ) );

$base_url = 'http://thewebsite.co.uk/';
$api_key = 'theykey';
$private_key = 'thekey';
$method  = 'GET';
$route = 'forms/1/entries';
$expires = strtotime( '+60 mins' );
$string_to_sign = sprintf( '%s:%s:%s:%s', $api_key, $method, $route, $expires );
$sig = self::calculate_signature( $string_to_sign, $private_key );
//include field filters in search querystring parameter
$url = $base_url . $route . '?api_key=' . $api_key . '&signature=' . $sig . '&expires=' . $expires . '&paging[page_size]=1000&search=' . $search_json;
?>

All I get though is Fatal error: Cannot access self:: when no class scope is active What does this mean? Any help would be great!


Solution

  • Instead of self:: you should use real class name like MyClass::. Self will work only inside methods defined in the class.