Skip to content

Conversation

Copy link

Copilot AI commented Nov 12, 2025

Implements webhook endpoint to detect when the /tenth Facebook page starts a live video, extract the video ID and title, and pass them to a handler method.

Implementation

REST API endpoint at /wp-json/shimmer/v1/facebook-webhook:

  • GET handler verifies webhook subscriptions using verify token
  • POST handler processes live video events with HMAC-SHA256 signature validation
  • Extracts video ID and title from payload when status === 'live' and calls FacebookWebhook::handleLiveVideo($videoId, $videoTitle)

Universal settings system at Settings → Shimmer:

  • Created ShimmerSettings class for centralized settings management across all Shimmer components
  • Facebook Webhook settings integrated as a section within the universal settings page
  • Admin UI for configuring App Secret and Verify Token
  • Falls back to wp-config.php constants for backward compatibility
  • Displays webhook URL and setup instructions inline
  • Fully internationalized using WordPress i18n functions

Files:

  • shimmer/ShimmerSettings.php - Universal settings system (new)
  • shimmer/FacebookWebhook.php - Webhook handler
  • shimmer.php - Initialization for both classes

Usage

// Stub method called when live video detected
public static function handleLiveVideo(string $videoId, string $videoTitle = ''): void
{
    $logMessage = "Facebook Live Video Detected - Video ID: {$videoId}";
    if (!empty($videoTitle)) {
        $logMessage .= ", Title: {$videoTitle}";
    }
    error_log($logMessage);
    // Customize: create post, send notifications, etc.
}

Settings stored as:

  • shimmer_facebook_app_secret option
  • shimmer_facebook_verify_token option

Webhook subscribes to the live_videos field on Facebook page.

Internationalization

All user-facing strings use WordPress i18n functions (__(), esc_html_e(), wp_kses_post()) with text domain shimmer, making the interface ready for translation.

Original prompt

In a new branch and mostly in new files, add functionality to this plugin that can connect to Facebook and:

  1. Use the webhook API to detect when the Facebook page /tenth has a new live video online,
  2. Get the video ID and provide it to a stub method,
  3. smoothly handle all auth.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits November 12, 2025 19:27
Co-authored-by: jkrrv <1238391+jkrrv@users.noreply.github.com>
Co-authored-by: jkrrv <1238391+jkrrv@users.noreply.github.com>
Co-authored-by: jkrrv <1238391+jkrrv@users.noreply.github.com>
Co-authored-by: jkrrv <1238391+jkrrv@users.noreply.github.com>
Co-authored-by: jkrrv <1238391+jkrrv@users.noreply.github.com>
Copilot AI changed the title [WIP] Add functionality to connect to Facebook and handle webhooks Add Facebook webhook integration for live video notifications Nov 12, 2025
Copilot AI requested a review from jkrrv November 12, 2025 19:35
@jkrrv
Copy link
Member

jkrrv commented Nov 12, 2025

@copilot Please also provide the stub method with the name of the video.
If you're going to add a settings interface, please move it to a different class and make it universal for all of Shimmer, not just the Facebook webhook component.
Please use i18n functions for anything that could be user-facing, including settings.

… add i18n

Co-authored-by: jkrrv <1238391+jkrrv@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 12, 2025

@copilot Please also provide the stub method with the name of the video.
If you're going to add a settings interface, please move it to a different class and make it universal for all of Shimmer, not...

Done in commit 978b2ab:

  1. Video name added to stub method: handleLiveVideo($videoId, $videoTitle) now receives both the video ID and title. The title is extracted from the webhook payload's title field (with fallback to description).

  2. Settings moved to universal class: Created ShimmerSettings class that manages all Shimmer plugin settings. Settings are now located at Settings > Shimmer with a dedicated Facebook Webhook section. This class is extensible for other Shimmer components.

  3. i18n functions applied: All user-facing strings now use __(), esc_html_e(), and wp_kses_post() with text domain shimmer. The settings page, field labels, descriptions, and instructions are all ready for translation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants