PHP code example of itmosoft / laravel-social-publishing

1. Go to this page and download the library: Download itmosoft/laravel-social-publishing library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

itmosoft / laravel-social-publishing example snippets


use ItmoSoft\SocialPublishing\SocialPublishingManager;

$manager = app(SocialPublishingManager::class);

$account = $manager->createAccount(
    owner: $user,
    platform: 'instagram',
    accountIdentifier: 'your-provider-account-id',
    credentials: ['access_token' => $accessToken],
);

$post = $manager->createPost(
    owner: $user,
    content: 'Hello from our Laravel application',
    media: ['https://example.com/image.jpg'],
);

$post = $manager->schedule($post, now()->addDay());

namespace App\Social;

use ItmoSoft\SocialPublishing\Contracts\SocialPlatformPublisher;
use ItmoSoft\SocialPublishing\Models\SocialAccount;
use ItmoSoft\SocialPublishing\Models\SocialPost;

class ExamplePlatformPublisher implements SocialPlatformPublisher
{
    public function publish(SocialAccount $account, SocialPost $post): array
    {
        // Call the provider SDK/API here.
        // Return provider response data, including its external post ID.
        return ['id' => 'provider-post-id'];
    }
}

use ItmoSoft\SocialPublishing\Contracts\SocialPlatformPublisher;

$publication = $manager->publish(
    $post,
    $account,
    app(SocialPlatformPublisher::class),
);
bash
composer vendor:publish --tag=itmosoft-social-publishing-config
php artisan vendor:publish --tag=itmosoft-social-publishing-migrations
php artisan migrate