Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Meetup Api Bundle Laravel Package

dms/meetup-api-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Run:

    composer require dms/meetup-api-bundle:~1.*
    

    Add to config/bundles.php:

    return [
        // ...
        DMS\Bundle\MeetupApiBundle\DMSMeetupApiBundle::class => ['all' => true],
    ];
    
  2. Configure API Key (Key Auth) Add to config/packages/dms_meetup_api.yaml:

    dms_meetup_api:
        client:
            key: "%env(MEETUP_API_KEY)%"
    

    Set the env var in .env:

    MEETUP_API_KEY=your_api_key_here
    
  3. First Use Case: Fetch Meetup Events Inject the client in a service:

    use DMS\Bundle\MeetupApiBundle\Client\MeetupClientInterface;
    
    class MeetupService
    {
        public function __construct(private MeetupClientInterface $client) {}
    
        public function getUpcomingEvents(string $groupUrlname)
        {
            return $this->client->get('/find/groups', [
                'group_urlname' => $groupUrlname,
                'fields' => 'events',
            ]);
        }
    }
    

Implementation Patterns

Common Workflows

  1. Service Integration Use dependency injection to access the client in controllers/services:

    // src/Service/MeetupEventService.php
    class MeetupEventService
    {
        public function __construct(
            private MeetupClientInterface $client,
            private MeetupOAuthClientInterface $oauthClient
        ) {}
    }
    
  2. OAuth Workflow Configure OAuth in config/packages/dms_meetup_api.yaml:

    dms_meetup_api:
        client:
            consumer_key: "%env(MEETUP_OAUTH_KEY)%"
            consumer_secret: "%env(MEETUP_OAUTH_SECRET)%"
            token: "%env(MEETUP_OAUTH_TOKEN)%"
            token_secret: "%env(MEETUP_OAUTH_TOKEN_SECRET)%"
    

    Use the OAuth client for user-specific requests:

    $this->oauthClient->get('/self', []);
    
  3. Pagination Handling Loop through paginated results:

    $offset = 0;
    do {
        $events = $this->client->get('/events', [
            'offset' => $offset,
            'order' => 'time',
        ]);
        // Process events...
        $offset += 20; // Meetup's default page size
    } while (count($events) > 0);
    
  4. Error Handling Wrap API calls in try-catch:

    try {
        $response = $this->client->get('/events');
    } catch (\DMS\MeetupApiClient\Exception\ApiException $e) {
        // Log or handle error (e.g., rate limit, invalid request)
        throw new \RuntimeException('Meetup API error: ' . $e->getMessage());
    }
    

Gotchas and Tips

Pitfalls

  1. API Key vs. OAuth Confusion

    • Key Auth: Use for public data (e.g., fetching group events).
    • OAuth: Required for private user data (e.g., /self or /rsvps).
    • Gotcha: Mixing auth types may cause 401 Unauthorized errors.
  2. Rate Limits

    • Meetup enforces rate limits. Cache responses aggressively:
      $cacheKey = 'meetup_events_' . $groupUrlname;
      if (!$events = $cache->get($cacheKey)) {
          $events = $this->client->get('/find/groups', ['group_urlname' => $groupUrlname]);
          $cache->set($cacheKey, $events, 3600); // Cache for 1 hour
      }
      
  3. Deprecated Endpoints

    • Some endpoints (e.g., /find/groups) may change. Check Meetup API docs for updates.
    • Tip: Use the fields parameter to limit response size:
      $this->client->get('/events', ['fields' => 'id,time,name']);
      
  4. Environment Variables

    • Hardcoding keys/secrets in config/ violates security best practices. Always use .env:
      # config/packages/dms_meetup_api.yaml
      dms_meetup_api:
          client:
              key: "%env(MEETUP_API_KEY)%"
      

Debugging Tips

  1. Enable Debug Mode Configure the client to log requests:

    dms_meetup_api:
        client:
            debug: true  # Logs requests/responses to Symfony's logger
    
  2. Inspect Raw Responses Access the underlying HTTP client for debugging:

    $response = $this->client->get('/events');
    $rawBody = $response->getBody()->getContents();
    
  3. Common HTTP Errors

    • 400 Bad Request: Validate query parameters (e.g., group_urlname).
    • 401 Unauthorized: Check OAuth tokens or API keys.
    • 404 Not Found: Verify endpoint URLs (e.g., /find/groups vs. /groups).

Extension Points

  1. Custom Clients Extend the base client for domain-specific logic:

    class CustomMeetupClient extends \DMS\MeetupApiClient\Client
    {
        public function getGroupEvents(string $groupUrlname, int $limit = 10)
        {
            return $this->get('/find/groups', [
                'group_urlname' => $groupUrlname,
                'fields' => 'events',
                'limit' => $limit,
            ]);
        }
    }
    

    Register it as a service:

    services:
        App\Service\CustomMeetupClient:
            arguments:
                - "%env(MEETUP_API_KEY)%"
            tags: ['dms_meetup_api.client']
    
  2. Event Subscribers Listen to Meetup API events (e.g., rate limits) via Symfony’s event dispatcher:

    // src/EventListener/MeetupRateLimitListener.php
    class MeetupRateLimitListener
    {
        public function onRateLimit(\DMS\MeetupApiClient\Event\RateLimitEvent $event)
        {
            $this->logger->warning('Meetup API rate limit reached. Retrying in 60s...');
            sleep(60);
        }
    }
    
  3. Testing Mock the client in PHPUnit:

    $mockClient = $this->createMock(MeetupClientInterface::class);
    $mockClient->method('get')->willReturn(['events' => []]);
    
    $service = new MeetupEventService($mockClient);
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cocosmos/filament-sticky-save-bar
patrickbussmann/oauth2-apple
3brs/enterprise-security-bundle
anousss007/vigilance
supportpal/eloquent-model
ardenexal/fhir-models
laravel-at/laravel-image-sanitize
romalytar/yammi-audit-log-laravel
ardenexal/fhir-validation
arshaviras/weather-widget
laravel-chronicle/core
sunchayn/nimbus
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope