Hi, I tested the mailwizz-php-sdk examples and they worked great.
But now I'm trying to test calling the SDK from within a controller of my Yii app, but can't make the Autoloader work.
I get this error: include(MailWizzApi_Config.php): failed to open stream: No such file or directory
Because my own App's autoloader is trying to find the class.
Note: the path of the require_once() is correct, the file can be found, but the autoloader doesn't work for some reason. The API keys are also correct.
But now I'm trying to test calling the SDK from within a controller of my Yii app, but can't make the Autoloader work.
I get this error: include(MailWizzApi_Config.php): failed to open stream: No such file or directory
Because my own App's autoloader is trying to find the class.
Note: the path of the require_once() is correct, the file can be found, but the autoloader doesn't work for some reason. The API keys are also correct.
PHP:
require_once( __DIR__ .'/../../mailwizz-php-sdk/MailWizzApi/Autoloader.php' );
class TestController extends Controller
{
protected function setupMailWizz()
{
MailWizzApi_Autoloader::register();
$config = new MailWizzApi_Config(array(
'apiUrl' => 'http://localdomain.loc/mailwizz/api/index.php',
'publicKey' => '...',
'privateKey' => '...',
// components
'components' => array(
'cache' => array(
'class' => 'MailWizzApi_Cache_File',
'filesPath' => __DIR__ .'/../../mailwizz-php-sdk/MailWizzApi/Cache/data/cache'
)
),
));
// now inject the configuration and we are ready to make api calls
MailWizzApi_Base::setConfig($config);
}
public function actionLists()
{
$this->setupMailWizz();
$endpoint = new MailWizzApi_Endpoint_Lists();
$response = $endpoint->getLists($pageNumber = 1, $perPage = 10);
// DISPLAY RESPONSE
echo '<pre>';
print_r($response->body);
echo '</pre>';
}