PHP code example of plin-code / laravel-instagram-digest
1. Go to this page and download the library: Download plin-code/laravel-instagram-digest 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/ */
plin-code / laravel-instagram-digest example snippets
use PlinCode\InstagramDigest\Facades\InstagramDigest;
public function boot(): void
{
InstagramDigest::hashtagsUsing(fn () => ['trekking', 'hiking', 'guidealpine']);
InstagramDigest::keywordsUsing(fn () => ['guida', 'trek', 'outdoor']);
InstagramDigest::minFollowersUsing(fn () => 5000);
}
use PlinCode\InstagramDigest\Facades\InstagramDigest;
use PlinCode\InstagramDigest\Models\Profile;
InstagramDigest::registerAction(
key: 'archive',
label: 'Archive',
handler: fn (Profile $p) => $p->update(['status' => 'archived']),
);
InstagramDigest::defaultActions([
new MyYesAction,
new MyNoAction,
]);
use PlinCode\InstagramDigest\Contracts\CardRenderer;
use PlinCode\InstagramDigest\Facades\InstagramDigest;
InstagramDigest::renderCardUsing(MyCardRenderer::class);
'route' => [
'prefix' => 'instagram-digest', // appears in the URL: /{prefix}/webhook/{secret?}
'middleware' => ['api'], // any middleware array — e.g. ['api', 'throttle:60,1']
],
use Illuminate\Support\Facades\Schedule;
Schedule::command('instagram-digest:scrape')->weekdays()->at('09:30');
Schedule::command('instagram-digest:send')->weekdays()->at('10:00');
public function handle(ProfileDiscovered $event): void
{
if (! $event->isNew) {
return;
}
Prospect::firstOrCreate(
['instagram_handle' => $event->profile->instagram_username],
['status' => 'new'],
);
}
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Event;
use PlinCode\InstagramDigest\Events\ProfileDiscovered;
use PlinCode\InstagramDigest\Jobs\RunHashtagScrapingJob;
it('my app reacts to ProfileDiscovered', function () {
Event::fake([ProfileDiscovered::class]);
Http::fake([
'api.apify.com/*' => Http::response([/* ... */], 200),
]);
dispatch_sync(new RunHashtagScrapingJob);
Event::assertDispatched(ProfileDiscovered::class);
});