PHP code example of mosamirzz / poller

1. Go to this page and download the library: Download mosamirzz/poller 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/ */

    

mosamirzz / poller example snippets


$result = Poller::do(
    fn () => Http::get("https://ads-api.tiktok.com/api/status/get/", [
        "advertiser_id" => 12345678,
        "task_id" => 23456789,
    ])
)->every(seconds: 5)
    ->failAfter(attempts: 3)
    ->stopWhen(
        fn (mixed $result): bool => $result["status"] == "SUCCESS"
    )
    ->onFail(function (Throwable $e) {
        Log::error("Got an error", [
            "msg" => $e->getMessage(),
            "code" => $e->getCode(),
        ]);
    })
    ->start();