client-php
client-php copied to clipboard
Uncaught Error: Call to undefined method Pipedrive\Configuration::setApiKey()
I'm using the following code from the example. I'm running PHP 7.4.3 and get this error "Uncaught Error: Call to undefined method Pipedrive\Configuration::setApiKey()"
$ssdpath = get_stylesheet_directory();
use Pipedrive\Configuration;
require_once($ssdpath . '/vendor/autoload.php');
// Create a Configuration object and set the API key as an array
// Configure API key authorization: api_key
$config = (new Pipedrive\Configuration())->setApiKey('api_token', 'YOUR_API_KEY');
$apiInstance = new Pipedrive\Api\ActivitiesApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
try {
$result = $apiInstance->getActivities();
echo '<pre>';
print_r($result);
echo '</pre>';
} catch (Exception $e) {
echo 'Exception when calling ActivitiesApi->getActivities: ', $e->getMessage(), PHP_EOL;
}
If I use just this code, i do not get any error:
$ssdpath = get_stylesheet_directory();
use Pipedrive\Configuration;
require_once($ssdpath . '/vendor/autoload.php');
// Create a Configuration object and set the API key as an array
$config = new \Pipedrive\Configuration();
So it seems like for whatever reason the setApiKey method is not available?
I have tried uninstalling pipedrive with composer and then reinstalling, and get the same result.
If it's of any consequence, I am using composer via SSH on a wpengine server. Thanks
Also please note that vendor/pipedrive/pipedrive/Configuration.php looks like this– and there is no method setApiKey()
<?php
/*
* Pipedrive
*
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
*/
namespace Pipedrive;
/**
* All configuration including auth info and base URI for the API access
* are configured in this class.
*/
class Configuration
{
/**
* The environment being used'
* @var string
*/
public static $environment = Environments::PRODUCTION;
public static $apiToken = '';
/**
* OAuth 2 Client ID
* @var string
*/
public static $oAuthClientId = 'TODO: Replace';
/**
* OAuth 2 Client Secret
* @var string
*/
public static $oAuthClientSecret = 'TODO: Replace';
/**
* OAuth 2 Redirection endpoint or Callback Uri
* @var string
*/
public static $oAuthRedirectUri = 'TODO: Replace';
/**
* OAuth 2 token
* @var \Pipedrive\Models\OAuthToken
*/
public static $oAuthToken = null;
/**
* OAuth token update callback
* Called whenever token is updated
* @var callable
*/
public static $oAuthTokenUpdateCallback = null;
/**
* Get the base uri for a given server in the current environment
* @param string $server Server name
* @return string Base URI
*/
public static function getBaseUri($server = Servers::DEFAULT_)
{
return APIHelper::appendUrlWithTemplateParameters(
static::$environmentsMap[static::$environment][$server],
array(
)
);
}
/**
* A map of all baseurls used in different environments and servers
* @var array
*/
private static $environmentsMap = array(
Environments::PRODUCTION => array(
Servers::DEFAULT_ => 'https://api.pipedrive.com/v1',
Servers::OAUTH => 'https://oauth.pipedrive.com',
),
);
}
I was able to resolve by manually installing the files.