Reputation: 105
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!
Upvotes: 0
Views: 165
Reputation: 6391
self
is special keyword which is "used to access properties or methods from inside the class definition" -- http://php.net/manual/en/language.oop5.paamayim-nekudotayim.php
First, ensure that the calculate_signature()
method is a static method. See http://php.net/manual/en/language.oop5.php.
I'm guessing it is, if so, then you can access it via it's class name rather than self
, i.e. ClassName::calculate_signature()
.
Read up on:
Upvotes: 0
Reputation: 7504
Instead of self:: you should use real class name like MyClass::. Self will work only inside methods defined in the class.
Upvotes: 1