Search code examples
phpapioauthmeetup

DMS Meetup.com API Client Class not found


I suspect the finer mechanics of this question are wider than just the specific class library I'm looking to use, in this instance it's the use case I'm struggling with.

I'm looking at implementing the DMS Meetup API for PHP ( https://github.com/rdohms/meetup-api-client ) yet having installed the codebase and project dependencies I'm getting the error

Fatal error: Class 'MeetupOAuthClient' not found in...

The basic structure I have is

require('vendor/autoload.php');
// OAuth Authentication
$config = array(
    'consumer_key'    => '*****',
    'consumer_secret' => '*****',
    'token'           => '*****',
    'token_secret'    => '*****',
);
$client = MeetupOAuthClient::factory($config);

It's suggesting the library isn't being loaded - but my understanding is the autoload.php should handle this no?


Solution

  • The DMS library uses namespaces, and you need to tell the autoloader where to find it in those namespaces.

    After your require line, add the following and things should work:

    use DMS\Service\Meetup\MeetupOAuthClient;
    

    You could also change the last line to the following and get a similar effect:

    $client = DMS\Service\Meetup\MeetupOAuthClient::factory($config);