<?php
namespace flow\social\publisher;
if (!defined('WPINC'))
	die;

/**
 * Facebook Publisher.
 *
 * Publishes text posts, link posts, and photo posts to a Facebook Page
 * via the Meta Graph API.
 *
 * Required permission: pages_manage_posts
 *
 * Endpoints:
 *   POST /{page-id}/feed   — text/link posts
 *   POST /{page-id}/photos — image posts
 *
 * @package   FlowFlow
 * @author    Looks Awesome <email@looks-awesome.com>
 * @link      http://looks-awesome.com
 * @copyright Looks Awesome
 */
class FFFacebookPublisher extends FFBasePublisher {

	const API_VERSION = 'v19.0';

	public function getNetwork() {
		return 'facebook';
	}

	/**
	 * @inheritDoc
	 */
	public function publish(array $postData) {
		$this->token = isset($postData['token']) ? $postData['token'] : '';
		$accountId   = isset($postData['account_id']) ? $postData['account_id'] : '';

		if (empty($this->token) || empty($accountId)) {
			return $this->errorResult('Missing Facebook token or page ID.');
		}

		$this->log('Publishing to Facebook', [
			'account_id' => $accountId,
			'has_text'   => !empty($postData['text']),
			'has_media'  => !empty($postData['media']),
		]);

		// TODO: Implement actual API call when ready
		// Determine endpoint based on media type:
		//   - Has image  → POST /{page-id}/photos
		//   - Has link   → POST /{page-id}/feed with link param
		//   - Text only  → POST /{page-id}/feed with message param

		return $this->errorResult('Facebook publishing is not yet implemented. API integration pending.');
	}
}
