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

Wall Poster Bundle Laravel Package

dario_swain/wall-poster-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require dario_swain/wall-poster-bundle:dev-master
    

    (Replace dev-master with a stable version from Packagist.)

  2. Register the Bundle Add to app/AppKernel.php:

    new WallPosterBundle\WallPosterBundle(),
    
  3. Configure Routing Import in app/config/routing.yml:

    WallPosterBundle:
        resource: "@WallPosterBundle/Resources/routing/routing.yml"
    
  4. Configure API Credentials Add to app/config/config.yml:

    wall_poster:
        vk:
            access_token: "YOUR_VK_ACCESS_TOKEN"
            group_id: "YOUR_VK_GROUP_ID"
        facebook:
            access_token: "YOUR_FB_ACCESS_TOKEN"
            app_id: "YOUR_FB_APP_ID"
            page: "YOUR_FB_PAGE_ID"
        twitter:
            api_key: "YOUR_TWITTER_API_KEY"
            api_secret: "YOUR_TWITTER_API_SECRET"
    
  5. First Use Case Post to VK:

    use WallPosterBundle\Service\PosterService;
    
    $poster = $this->get('wall_poster.poster_service');
    $poster->postToVk('Hello, social world!');
    

Implementation Patterns

Core Workflows

  1. Posting Content Use the PosterService to publish to any supported platform:

    $poster->postToVk($message, ['attachments' => ['photo123']]);
    $poster->postToFacebook($message, ['link' => 'https://example.com']);
    $poster->postToTwitter($message);
    
  2. Handling Captchas (VK-Specific) If VK blocks your API, use the /wall-poster/captcha route to submit a captcha:

    $captchaService = $this->get('wall_poster.captcha_service');
    $captchaService->submitCaptcha('captcha_sid', 'captcha_text');
    
  3. Event-Driven Posting Trigger posts via events (e.g., after a model is saved):

    // In your event subscriber
    $poster->postToVk("New blog post: {$post->title}");
    
  4. Batch Posting Loop through items and post sequentially:

    foreach ($newsItems as $item) {
        $poster->postToFacebook($item->content);
    }
    

Integration Tips

  • Laravel Service Container Bind the bundle’s services to your container for easier access:

    $this->app->bind('wall_poster.poster_service', function($app) {
        return new PosterService($app['wall_poster.config']);
    });
    
  • Configuration Overrides Override defaults in config/packages/wall_poster.yaml (if using Symfony Flex):

    wall_poster:
        vk:
            group_id: "%env(VK_GROUP_ID)%"
    
  • Logging Failures Wrap posting logic in a try-catch to log errors:

    try {
        $poster->postToTwitter($message);
    } catch (\Exception $e) {
        \Log::error("Twitter post failed: " . $e->getMessage());
    }
    

Gotchas and Tips

Pitfalls

  1. API Rate Limits

    • VK/Facebook/Twitter enforce rate limits. Implement exponential backoff in your retry logic.
    • Example:
      $attempts = 0;
      while ($attempts < 3) {
          try {
              $poster->postToTwitter($message);
              break;
          } catch (\RuntimeException $e) {
              $attempts++;
              sleep(2 ** $attempts); // Exponential delay
          }
      }
      
  2. Captcha Handling (VK)

    • If VK blocks your IP, the /wall-poster/captcha route must be accessible. Ensure:
      • The route is not blocked by middleware (e.g., CSRF).
      • The captcha service is properly configured in config.yml.
  3. Deprecated Methods

    • The bundle is in dev-master. Check for breaking changes in future updates (e.g., renamed methods like postToVkontaktepostToVk).
  4. Missing Dependencies

    • Ensure guzzlehttp/guzzle is installed (required for HTTP requests):
      composer require guzzlehttp/guzzle
      

Debugging

  • Enable Debug Mode Add to config.yml:

    wall_poster:
        debug: true
    

    This logs raw API responses for troubleshooting.

  • Validate Tokens Test tokens manually before integrating:

    curl -X GET "https://api.vk.com/method/users.get?access_token=YOUR_TOKEN&v=5.131"
    

Extension Points

  1. Custom Post Formats Extend the PosterService to support custom payloads:

    class CustomPosterService extends PosterService {
        public function postCustomToVk($message, array $options) {
            $payload = array_merge([
                'message' => $message,
                'owner_id' => '-'.$this->config['vk']['group_id'],
            ], $options);
            return $this->httpClient->post('https://api.vk.com/method/wall.post', $payload);
        }
    }
    
  2. Add New Platforms Implement a new poster class (e.g., LinkedInPoster) and register it as a service:

    services:
        wall_poster.linkedin_poster:
            class: App\Service\LinkedInPoster
            arguments: ['@wall_poster.config']
    
  3. Queue Delayed Posts Use Laravel Queues to schedule posts:

    $poster->postToVk($message)->delay(now()->addMinutes(10));
    

    (Requires custom queue logic in the bundle.)

Configuration Quirks

  • Environment Variables Avoid hardcoding tokens. Use .env:

    wall_poster:
        vk:
            access_token: "%env(VK_ACCESS_TOKEN)%"
    

    (Ensure env() is loaded in config.yml.)

  • Facebook App Secret The app_secret is only needed for server-side validation (e.g., webhooks). Omit if unused.

  • Twitter API v2 The bundle may not support Twitter’s v2 API. Check the source for api_key vs. bearer_token usage.

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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours