### Install SerwerSMS Laravel Package Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Install the package using Composer and register the service provider and configuration in app/config/app.php. Ensure to replace placeholder credentials with your actual API login and password. ```json { "require": { "serwer/sms": "dev-master" }, "repositories": [{ "type": "vcs", "url": "https://github.com/SerwerSMSpl/serwersms-laravel5.git" }] } ``` ```php return [ 'providers' => [ // ... Serwer\Sms\SmsServiceProvider::class, ], 'sms' => [ 'username' => 'login_api', 'password' => 'haslo_api', 'api_url' => 'https://api2.serwersms.pl/', 'format' => 'json' // lub 'xml' ] ]; ``` -------------------------------- ### Install SerwerSMS Laravel5 Package with Composer Source: https://github.com/serwersmspl/serwersms-laravel5/blob/master/README.md Add this configuration to your composer.json file to install the SerwerSMS Laravel5 package. Ensure you include the VCS repository for direct installation from GitHub. ```json { "require": { "serwer/sms": "dev-master" } ... "repositories" : [ { "type" : "vcs", "url" : "https://github.com/SerwerSMSpl/serwersms-laravel5.git" } ] } ``` -------------------------------- ### Manage Message Templates: Add, List, Edit, Delete Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt This example covers the management of SMS message templates. You can add new templates with a name and text, list existing templates, edit them, and delete them. Templates can include placeholders like {NR} and {DATA}. ```php try { $serwersms = new SMS; // Dodanie szablonu $result = $serwersms->templates->add( 'Potwierdzenie zamówienia', 'Dziękujemy za zamówienie nr {NR}. Przewidywana dostawa: {DATA}.' ); $tplId = $result->id; // Lista szablonów $list = $serwersms->templates->index(['order' => 'asc']); foreach ($list->items as $t) { echo 'ID: ' . $t->id . ' | ' . $t->name . ': ' . $t->text . PHP_EOL; } // Edycja szablonu $serwersms->templates->edit($tplId, 'Potwierdzenie zamówienia v2', 'Zamówienie {NR} przyjęte. Dostawa: {DATA}.'); // Usunięcie szablonu $serwersms->templates->delete($tplId); } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Get Sending Statistics: Filter by Type and Date Range Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Retrieve aggregated statistics for sent messages. This snippet shows how to filter statistics by message type (eco, full, voice, mms) and a specific date range. The results include delivery, pending, undelivered, and unsent counts. ```php try { $serwersms = new SMS; $stats = $serwersms->stats->index([ 'type' => 'full', // eco|full|voice|mms 'begin' => '2024-01-01', 'end' => '2024-01-31', ]); foreach ($stats->items as $s) { echo 'Kampania: ' . $s->name . PHP_EOL; echo 'Typ: ' . $s->type . PHP_EOL; echo 'Doręczone: ' . $s->delivered . PHP_EOL; echo 'Oczekujące: ' . $s->pending . PHP_EOL; echo 'Niedoręczone: ' . $s->undelivered . PHP_EOL; echo 'Niewysłane: ' . $s->unsent . PHP_EOL; echo 'Okres: ' . $s->begin . ' — ' . $s->end . PHP_EOL; echo '---' . PHP_EOL; } } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Configure SerwerSMS Service Provider Source: https://github.com/serwersmspl/serwersms-laravel5/blob/master/README.md Add the SerwerSMS service provider and configure your API credentials in the app.php configuration file. ```php return [ ... ... 'providers' => [ ... ... Serwer\Sms\SmsServiceProvider::class, ], 'sms'=>[ 'username' => 'username', 'password' => 'password', 'api_url' => 'https://api2.serwersms.pl/', 'format' => 'json' ] ] ``` -------------------------------- ### Manage Account Settings with SerwerSMS SDK Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Retrieve SMS limits, contact details, administrator messages, and register new accounts. Requires the SMS class to be initialized. ```php try { $serwersms = new SMS; // Limity wiadomości przypisane do konta $limits = $serwersms->account->limits(['show_type' => true]); foreach ($limits->items as $limit) { echo 'Typ: ' . $limit->type . PHP_EOL; echo 'Limit: ' . $limit->value . PHP_EOL; echo 'Max znaków: ' . $limit->chars_limit . PHP_EOL; } // Dane kontaktowe i opiekun konta $help = $serwersms->account->help(); echo 'Telefon: ' . $help->telephone . PHP_EOL; echo 'E-mail: ' . $help->email . PHP_EOL; echo 'Opiekun: ' . $help->account_maintainer->name . PHP_EOL; // Wiadomości od administratora $msgs = $serwersms->account->messages(); if ($msgs->new) { echo 'Nowa wiadomość: ' . $msgs->message . PHP_EOL; } // Rejestracja nowego konta $reg = $serwersms->account->add([ 'phone' => '+48500600700', 'email' => 'nowy@example.com', 'first_name' => 'Marek', 'last_name' => 'Nowak', 'company' => 'Nowa Firma Sp. z o.o.', ]); echo 'Konto zarejestrowane: ' . ($reg->success ? 'tak' : 'nie') . PHP_EOL; } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Manage Subaccounts: Add, List, Set Limits, View, Delete Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt This code demonstrates managing API subaccounts. You can create new subaccounts, list existing ones, set message sending limits, view subaccount details, and delete them. The 'add' method can optionally use an existing subaccount ID for configuration. ```php try { $serwersms = new SMS; // Tworzenie podkonta (na wzór istniejącego podkonta o ID 1) $result = $serwersms->subaccounts->add('api_sub1', 'bezpieczneHaslo!', 1, [ 'name' => 'Dział Marketingu', 'phone' => '+48100200300', 'email' => 'marketing@firma.pl', ]); // Lista podkont $list = $serwersms->subaccounts->index(); foreach ($list->items as $sub) { echo 'ID: ' . $sub->id . ' | Login: ' . $sub->username . PHP_EOL; } // Ustawienie limitu wiadomości (np. 500 SMS ECO miesięcznie) $serwersms->subaccounts->limit($result->id, 'eco', 500); $serwersms->subaccounts->limit($result->id, 'full', 200); // Podgląd szczegółów $sub = $serwersms->subaccounts->view($result->id); echo 'Podkonto: ' . $sub->username . ' (' . $sub->name . ')' . PHP_EOL; // Usunięcie podkonta $serwersms->subaccounts->delete($result->id); } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Manage Contacts with PHP Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Enables creating and managing an address book, assigning contacts to groups, and using them as message recipients. Supports adding, listing with search, editing, bulk import, and deleting contacts. Ensure correct group IDs and phone number formats. ```php try { $serwersms = new SMS; // Dodanie kontaktu do grupy o ID 5 $result = $serwersms->contacts->add(5, '+48500600700', [ 'first_name' => 'Jan', 'last_name' => 'Kowalski', 'email' => 'jan@example.com', 'company' => 'Firma ABC', 'description' => 'Klient VIP', ]); $contactId = $result->id; // Lista kontaktów z wyszukiwaniem $contacts = $serwersms->contacts->index(5, 'Kowalski', ['limit' => 10, 'order' => 'asc']); foreach ($contacts->items as $c) { echo $c->first_name . ' ' . $c->last_name . ' — ' . $c->phone . PHP_EOL; } // Edycja kontaktu $serwersms->contacts->edit($contactId, 5, '+48500600700', ['description' => 'Klient Premium']); // Import zbiorczy $toImport = [ ['phone' => '500111222', 'first_name' => 'Anna', 'last_name' => 'Nowak', 'email' => 'anna@example.com'], ['phone' => '600333444', 'first_name' => 'Piotr', 'last_name' => 'Wiśniewski'], ]; $imp = $serwersms->contacts->import('Nowa Grupa', $toImport); echo 'Zaimportowano: ' . $imp->correct . ', błędy: ' . $imp->failed . PHP_EOL; // Usunięcie kontaktu $serwersms->contacts->delete($contactId); } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Manage Payments and Invoices with SerwerSMS SDK Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Retrieve payment history and download PDF invoices. Ensure the SMS class is correctly instantiated. ```php try { $serwersms = new SMS; // Lista wszystkich płatności $payments = $serwersms->payments->index(); foreach ($payments->items as $p) { echo 'Numer: ' . $p->number . PHP_EOL; echo 'Stan: ' . $p->state . PHP_EOL; // paid|not_paid echo 'Zapłacono: ' . $p->paid . ' / ' . $p->total . PHP_EOL; echo 'Termin: ' . $p->payment_to . PHP_EOL; echo 'URL: ' . $p->url . PHP_EOL; } // Szczegóły pojedynczej płatności $payment = $serwersms->payments->view($payments->items[0]->id); echo 'Faktura nr: ' . $payment->number . PHP_EOL; // Pobranie faktury PDF $pdf = $serwersms->payments->invoice($payment->id); file_put_contents('faktura_' . $payment->number . '.pdf', $pdf); } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Handle Premium SMS with SerwerSMS SDK Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Process incoming premium SMS messages, send replies, and view quiz results. Requires correct instantiation of the SMS class. ```php try { $serwersms = new SMS; // Lista odebranych SMS Premium $premiums = $serwersms->premium->index(); foreach ($premiums->items as $p) { echo 'ID: ' . $p->id . PHP_EOL; echo 'Do: ' . $p->to_number . PHP_EOL; // numer premium echo 'Od: ' . $p->from_number . PHP_EOL; echo 'Treść: ' . $p->text . PHP_EOL; echo 'Limit: ' . $p->limit . PHP_EOL; // Wysyłka odpowiedzi $reply = $serwersms->premium->send( $p->from_number, 'Dziękujemy za wiadomość! Oddzwonimy wkrótce.', $p->to_number, $p->id ); echo 'Odpowiedź wysłana: ' . ($reply->success ? 'tak' : 'nie') . PHP_EOL; } // Podgląd wyników quizu $quiz = $serwersms->premium->quiz(42); echo 'Quiz: ' . $quiz->name . PHP_EOL; foreach ($quiz->items as $opt) { echo 'Opcja ID ' . $opt->id . ': ' . $opt->count . ' odpowiedzi' . PHP_EOL; } } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Manage MMS and Voice Files with PHP Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Handles MMS and voice file management, including adding files via URL or binary data, listing, viewing, and deleting them. Ensure proper exception handling for API calls. ```php try { $serwersms = new SMS; // Dodanie pliku przez URL $result = $serwersms->files->add('mms', ['url' => 'https://example.com/obrazek.jpg']); $fileId = $result->id; echo 'Dodano plik ID: ' . $fileId . PHP_EOL; // Lista plików danego typu $list = $serwersms->files->index('mms'); // 'mms' lub 'voice' foreach ($list->items as $file) { echo $file->id . ' | ' . $file->name . ' | ' . $file->size . ' B | ' . $file->date . PHP_EOL; } // Podgląd pojedynczego pliku $file = $serwersms->files->view($fileId, 'mms'); echo 'Nazwa: ' . $file->name . ', Typ: ' . $file->type . PHP_EOL; // Usunięcie pliku $del = $serwersms->files->delete($fileId, 'mms'); echo 'Usunięto: ' . ($del->success ? 'tak' : 'nie') . PHP_EOL; } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Send SMS, MMS, and Voice Messages Source: https://github.com/serwersmspl/serwersms-laravel5/blob/master/README.md Demonstrates sending different types of messages (full SMS, ECO SMS, Voice, MMS) using the SerwerSMS client. Includes error handling. ```php try{ $serwersms = new \SMS; // SMS FULL $result = $serwersms->messages->sendSms( array( '+48500600700', '+48600700800' ), 'Test FULL message', 'INFORMACJA', array( 'test' => true, 'details' => true ) ); // SMS ECO $result = $serwersms->messages->sendSms( array( '+48500600700', '+48600700800' ), 'Test ECO message', null, array( 'test' => true, 'details' => true ) ); // VOICE from text $result = $serwersms->messages->sendVoice( array( '+48500600700', '+48600700800' ), array( 'text' => 'Test message', 'test' => true, 'details' => true ) ); // MMS $list = $serwersms->files->index('mms'); $result = $serwersms->messages->sendMms( array( '+48500600700', '+48600700800' ), 'MMS Title', array( 'test' => true, 'file_id' => $list->items[0]->id, 'details' => true ) ); echo 'Skolejkowano: '.$result->queued.'
'; echo 'Niewysłano: '.$result->unsent.'
'; foreach($result->items as $sms){ echo 'ID: '.$sms->id.'
'; echo 'NUMER: '.$sms->phone.'
'; echo 'STATUS: '.$sms->status.'
'; echo 'CZĘŚCI: '.$sms->parts.'
'; echo 'WIADOMOŚĆ: '.$sms->text.'
'; } } catch(Exception $e){ echo 'ERROR: '.$e->getMessage(); } ``` -------------------------------- ### messages->sendVoice() - Sending Voice Message (VMS) Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Sends a voice message either as a text-to-speech synthesis or using a pre-uploaded WAV file. The file must be uploaded via `files->add('voice', ...)` first. ```APIDOC ## messages->sendVoice() - Sending Voice Message (VMS) ### Description Sends a voice message as speech synthesis from text or as a WAV file. To send from a file, it must be uploaded beforehand using `files->add('voice', ...)`. ### Method ```php $serwersms->messages->sendVoice($recipients, $options) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **recipients** (array|string) - Required - An array of phone numbers or a single phone number. - **options** (array) - Required - An array of options for the voice message: - **text** (string) - Optional - The text to be synthesized into speech. Required if `file_id` is not provided. - **file_id** (string) - Optional - The ID of a pre-uploaded WAV file. Required if `text` is not provided. - **test** (bool) - Optional - If true, tests the sending without actual dispatch. - **details** (bool) - Optional - If true, returns detailed information about each message. ### Request Example ```php try { $serwersms = new \SMS; // VMS from text (speech synthesis) $result = $serwersms->messages->sendVoice( ['+48500600700', '+48600700800'], [ 'text' => 'Przypomnienie: wizyta jutro o godzinie dziesiątej.', 'test' => false, 'details' => true, ] ); // VMS from WAV file $files = $serwersms->files->index('voice'); $fileId = $files->items[0]->id; $result = $serwersms->messages->sendVoice( ['+48500600700'], ['file_id' => $fileId, 'details' => true] ); foreach ($result->items as $msg) { echo 'ID: ' . $msg->id . ' Status: ' . $msg->status . PHP_EOL; } } catch (Exception $e) { echo 'ERROR: ' . $e->getMessage(); } ``` ### Response #### Success Response (200) - **items** (array) - An array of objects, each representing a voice message status: - **id** (string) - The unique ID of the voice message. - **status** (string) - The status of the voice message (e.g., 'queued', 'sent'). ``` -------------------------------- ### Manage Contact Groups with PHP Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Allows creating contact groups for sending messages to entire groups at once using `group_id`. Supports adding, listing, checking membership, sending messages to groups, editing, and deleting groups. Ensure the `group_id` is correctly referenced. ```php try { $serwersms = new SMS; // Tworzenie grupy $result = $serwersms->groups->add('Klienci VIP'); $groupId = $result->id; // Lista grup $groups = $serwersms->groups->index(null, ['order' => 'asc']); foreach ($groups->items as $g) { echo 'ID: ' . $g->id . ' | Nazwa: ' . $g->name . ' | Kontaktów: ' . $g->count . PHP_EOL; } // Sprawdzenie grup przypisanych do numeru $membership = $serwersms->groups->check('+48500600700'); echo 'Grupy numeru: ' . $membership->group_name . PHP_EOL; // Wysyłka do całej grupy $result = $serwersms->messages->sendSms( null, 'Promocja tylko dla VIP!', 'MÓJSKLEP', ['group_id' => $groupId, 'details' => true] ); // Edycja i usunięcie $serwersms->groups->edit($groupId, 'Klienci Premium'); $serwersms->groups->delete($groupId); } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Send Voice Messages (VMS) Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Send voice messages either by synthesizing speech from text or by using a pre-uploaded WAV file. Use 'file_id' to specify a WAV file previously uploaded via 'files->add('voice', ...)'. ```php try { $serwersms = new \SMS; // VMS z tekstu (synteza mowy) $result = $serwersms->messages->sendVoice( ['+48500600700', '+48600700800'], [ 'text' => 'Przypomnienie: wizyta jutro o godzinie dziesiątej.', 'test' => false, 'details' => true, ] ); // VMS z pliku WAV $files = $serwersms->files->index('voice'); $fileId = $files->items[0]->id; $result = $serwersms->messages->sendVoice( ['+48500600700'], ['file_id' => $fileId, 'details' => true] ); foreach ($result->items as $msg) { echo 'ID: ' . $msg->id . ' Status: ' . $msg->status . PHP_EOL; } } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### File Management (MMS and Voice) Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Manage multimedia files for MMS and voice messages. Files can be added via URL or binary data, listed, viewed, and deleted. ```APIDOC ## files->add() / index() / view() / delete() ### Description Manages multimedia files used for sending MMS and voice messages. Files can be added via URL or directly as binary data. ### Method - `add(string $type, array $params)`: Adds a file. `$type` can be 'mms' or 'voice'. `$params` can include 'url' or 'file_content'. - `index(string $type)`: Lists files of a given type ('mms' or 'voice'). - `view(string $fileId, string $type)`: Retrieves details of a single file. - `delete(string $fileId, string $type)`: Deletes a file. ### Example Usage ```php try { $serwersms = new SMS; // Add file via URL $result = $serwersms->files->add('mms', ['url' => 'https://example.com/image.jpg']); $fileId = $result->id; echo 'Added file ID: ' . $fileId . PHP_EOL; // List files of a given type $list = $serwersms->files->index('mms'); // 'mms' or 'voice' foreach ($list->items as $file) { echo $file->id . ' | ' . $file->name . ' | ' . $file->size . ' B | ' . $file->date . PHP_EOL; } // View a single file $file = $serwersms->files->view($fileId, 'mms'); echo 'Name: ' . $file->name . ', Type: ' . $file->type . PHP_EOL; // Delete a file $del = $serwersms->files->delete($fileId, 'mms'); echo 'Deleted: ' . ($del->success ? 'yes' : 'no') . PHP_EOL; } catch (Exception $e) { echo 'ERROR: ' . $e->getMessage(); } ``` ``` -------------------------------- ### Group Management Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Create contact groups and send messages to entire groups at once. ```APIDOC ## groups->add() / index() / edit() / delete() / check() ### Description Allows for the creation of contact groups and sending messages to entire groups at once using the `group_id` parameter in sending methods. ### Method - `add(string $name)`: Creates a new group. - `index(int|null $groupId, array $options)`: Lists groups, with options for filtering by ID and ordering. - `check(string $phone)`: Checks which groups a phone number is assigned to. - `edit(string $groupId, string $newName)`: Edits the name of an existing group. - `delete(string $groupId)`: Deletes a group. ### Example Usage ```php try { $serwersms = new SMS; // Create group $result = $serwersms->groups->add('VIP Clients'); $groupId = $result->id; // List groups $groups = $serwersms->groups->index(null, ['order' => 'asc']); foreach ($groups->items as $g) { echo 'ID: ' . $g->id . ' | Name: ' . $g->name . ' | Contacts: ' . $g->count . PHP_EOL; } // Check groups assigned to a number $membership = $serwersms->groups->check('+48500600700'); echo 'Number groups: ' . $membership->group_name . PHP_EOL; // Send message to entire group $result = $serwersms->messages->sendSms( null, 'Promotion only for VIPs!', 'MYSHOP', ['group_id' => $groupId, 'details' => true] ); // Edit and delete $serwersms->groups->edit($groupId, 'Premium Clients'); $serwersms->groups->delete($groupId); } catch (Exception $e) { echo 'ERROR: ' . $e->getMessage(); } ``` ``` -------------------------------- ### Payments and Invoices Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Retrieve payment history and download invoices in PDF format. ```APIDOC ## payments->index() / view() / invoice() ### Description Retrieves payment history and allows downloading invoices in PDF format. ### Methods - `index()`: Retrieves a list of all payments. - `view(id)`: Retrieves details for a specific payment. - `invoice(id)`: Downloads the invoice for a specific payment in PDF format. ### Usage Example ```php try { $serwersms = new \SMS; // List all payments $payments = $serwersms->payments->index(); foreach ($payments->items as $p) { echo 'Number: ' . $p->number . PHP_EOL; echo 'State: ' . $p->state . PHP_EOL; // paid|not_paid echo 'Paid: ' . $p->paid . ' / ' . $p->total . PHP_EOL; echo 'Due Date: ' . $p->payment_to . PHP_EOL; echo 'URL: ' . $p->url . PHP_EOL; } // Details of a single payment $payment = $serwersms->payments->view($payments->items[0]->id); echo 'Invoice No: ' . $payment->number . PHP_EOL; // Download PDF invoice $pdf = $serwersms->payments->invoice($payment->id); file_put_contents('invoice_' . $payment->number . '.pdf', $pdf); } catch (Exception $e) { echo 'ERROR: ' . $e->getMessage(); } ``` ``` -------------------------------- ### View and Delete Messages Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Fetches details for a single message or deletes a scheduled message from the queue. Use 'show_contact' to include contact details. ```php try { $serwersms = new SMS; // Podgląd pojedynczej wiadomości $sms = $serwersms->messages->view('aca3944055', ['show_contact' => true]); echo 'Status: ' . $sms->status . PHP_EOL; // delivered|undelivered|sent|unsent|in_progress|saved echo 'Typ: ' . $sms->type . PHP_EOL; // eco|full|mms|voice echo 'Treść: ' . $sms->text . PHP_EOL; if (isset($sms->contact)) { echo 'Imię: ' . $sms->contact->first_name . ' ' . $sms->contact->last_name . PHP_EOL; } // Usunięcie zaplanowanej wiadomości $del = $serwersms->messages->delete(['aca3944055', 'bcf4051166']); echo 'Usunięto: ' . ($del->success ? 'tak' : 'nie') . PHP_EOL; } catch (Exception $e) { echo 'BD: ' . $e->getMessage(); } ``` -------------------------------- ### Manage Blacklist: Add, Check, List, Delete Numbers Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Use this snippet to manage the blacklist of phone numbers. Ensure the SMS class is correctly instantiated. Operations include adding numbers, checking their status, listing all blocked numbers, and removing them. ```php try { $serwersms = new SMS; // Dodanie numeru do czarnej listy $result = $serwersms->blacklist->add('+48500600700'); echo 'Dodano: ' . ($result->success ? 'tak' : 'nie') . ', ID: ' . $result->id . PHP_EOL; // Sprawdzenie czy numer jest na czarnej liście $check = $serwersms->blacklist->check('+48500600700'); echo 'Na czarnej liście: ' . ($check->exists ? 'tak' : 'nie') . PHP_EOL; // Lista zablokowanych numerów $list = $serwersms->blacklist->index(null, ['page' => 1, 'limit' => 20]); foreach ($list->items as $item) { echo $item->phone . ' (dodano: ' . $item->added . ')' . PHP_EOL; } // Usunięcie z czarnej listy $del = $serwersms->blacklist->delete('+48500600700'); echo 'Usunięto: ' . ($del->success ? 'tak' : 'nie') . PHP_EOL; } catch (Exception $e) { echo 'BŁĄD: ' . $e->getMessage(); } ``` -------------------------------- ### Fetch Incoming Messages Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Retrieves a list of incoming messages, including ECO replies, ND/NDI messages, or MMS. Can filter by date and read status. ```php try { $serwersms = new SMS; // Typ: eco|nd|ndi|mms $result = $serwersms->messages->recived('ndi', [ 'date_from' => '2024-01-01', 'date_to' => '2024-01-31', 'read' => true, // oznacz jako przeczytane 'limit' => 20, 'order' => 'desc', ]); foreach ($result->items as $sms) { echo 'ID: ' . $sms->id . PHP_EOL; echo 'Typ: ' . $sms->type . PHP_EOL; echo 'Numer: ' . $sms->phone . PHP_EOL; echo 'Data: ' . $sms->recived . PHP_EOL; echo 'Czarna lista: '. ($sms->blacklist ? 'tak' : 'nie') . PHP_EOL; echo 'Treść: ' . $sms->text . PHP_EOL; echo '--- '; } } catch (Exception $e) { echo 'BD: ' . $e->getMessage(); } ``` -------------------------------- ### Send MMS with Attachment Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Sends an MMS message with an attachment. The file must be previously uploaded using `files->add('mms', ...)` and its ID provided. ```php try { $serwersms = new SMS; // Pobranie listy plików MMS i użycie pierwszego $list = $serwersms->files->index('mms'); $result = $serwersms->messages->sendMms( ['+48500600700', '+48600700800'], 'Oferta specjalna!', // tytuł MMS (max 40 znaków) [ 'file_id' => $list->items[0]->id, 'test' => false, 'details' => true, ] ); echo 'Skolejkowano: ' . $result->queued . PHP_EOL; foreach ($result->items as $mms) { echo $mms->phone . ': ' . $mms->status . PHP_EOL; } } catch (Exception $e) { echo 'BD: ' . $e->getMessage(); } ``` -------------------------------- ### messages->sendMms() Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Sends an MMS message with an attachment. The file must be previously uploaded using `files->add('mms', ...)` and its ID provided in the parameters. ```APIDOC ## messages->sendMms() ### Description Sends an MMS message with an attachment. The file must be previously uploaded using `files->add('mms', ...)` and its ID provided in the parameters. ### Method POST (assumed based on action) ### Endpoint /messages/sendMms (assumed based on method name) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **phones** (array) - Required - Array of phone numbers to send the MMS to. - **title** (string) - Required - Title of the MMS (max 40 characters). - **options** (object) - Optional - Additional options for the MMS. - **file_id** (string) - Required - The ID of the uploaded MMS file. - **test** (boolean) - Optional - If true, sends a test MMS. Defaults to false. - **details** (boolean) - Optional - If true, includes detailed information in the response. Defaults to false. ### Request Example ```php $serwersms->messages->sendMms( ['+48500600700', '+48600700800'], 'Oferta specjalna!', [ 'file_id' => $list->items[0]->id, 'test' => false, 'details' => true, ] ); ``` ### Response #### Success Response (200) - **queued** (integer) - Number of messages queued for sending. - **items** (array) - Array of objects, each containing details about the sent MMS. - **phone** (string) - The recipient's phone number. - **status** (string) - The status of the sent MMS. #### Response Example ```json { "queued": 2, "items": [ { "phone": "+48500600700", "status": "queued" }, { "phone": "+48600700800", "status": "queued" } ] } ``` ``` -------------------------------- ### Retrieve SMS Delivery Reports Source: https://github.com/serwersmspl/serwersms-laravel5/blob/master/README.md Fetches delivery reports for specified SMS messages using their IDs. Processes and displays details for each report. ```php try{ $serwersms = new \SMS; // Get messages reports $result = $serwersms->messages->reports(array('id' => array('aca3944055'))); foreach($result->items as $sms){ echo 'ID: '.$sms->id.'
'; echo 'NUMER: '.$sms->phone.'
'; echo 'STATUS: '.$sms->status.'
'; echo 'SKOLEJKOWANO: '.$sms->queued.'
'; echo 'WYSŁANO: '.$sms->sent.'
'; echo 'DORĘCZONO: '.$sms->delivered.'
'; echo 'NADAWCA: '.$sms->sender.'
'; echo 'TYP: '.$sms->type.'
'; echo 'WIADOMOŚĆ: '.$sms->text.'
'; } } catch(Exception $e){ echo 'ERROR: '.$e->getMessage(); } ``` -------------------------------- ### Premium SMS Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Handle incoming Premium SMS messages, send replies, and view quiz results. ```APIDOC ## premium->index() / send() / quiz() ### Description Handles incoming Premium SMS messages and allows sending replies and viewing quiz results. ### Methods - `index()`: Retrieves a list of received Premium SMS messages. - `send(from_number, text, to_number, id)`: Sends a reply to a Premium SMS message. - `quiz(id)`: Retrieves the results for a specific quiz. ### Usage Example ```php try { $serwersms = new \SMS; // List of received Premium SMS $premiums = $serwersms->premium->index(); foreach ($premiums->items as $p) { echo 'ID: ' . $p->id . PHP_EOL; echo 'To: ' . $p->to_number . PHP_EOL; // premium number echo 'From: ' . $p->from_number . PHP_EOL; echo 'Text: ' . $p->text . PHP_EOL; echo 'Limit: ' . $p->limit . PHP_EOL; // Send a reply $reply = $serwersms->premium->send( $p->from_number, 'Thank you for your message! We will call you back soon.', $p->to_number, $p->id ); echo 'Reply sent: ' . ($reply->success ? 'yes' : 'no') . PHP_EOL; } // View quiz results $quiz = $serwersms->premium->quiz(42); echo 'Quiz: ' . $quiz->name . PHP_EOL; foreach ($quiz->items as $opt) { echo 'Option ID ' . $opt->id . ': ' . $opt->count . ' responses' . PHP_EOL; } } catch (Exception $e) { echo 'ERROR: ' . $e->getMessage(); } ``` ``` -------------------------------- ### Account Management Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Retrieve SMS limits, contact details of your account manager, messages from the administrator, and register a new account. ```APIDOC ## account->limits() / help() / messages() / add() ### Description Retrieves SMS limits, account manager contact details, administrator messages, and allows new account registration. ### Methods - `limits(options)`: Retrieves SMS limits assigned to the account. `options` can include `show_type` (boolean). - `help()`: Retrieves contact details and account manager information. - `messages()`: Retrieves messages from the administrator. - `add(data)`: Registers a new account. `data` is an associative array with keys like `phone`, `email`, `first_name`, `last_name`, `company`. ### Usage Example ```php try { $serwersms = new \SMS; // Account SMS limits $limits = $serwersms->account->limits(['show_type' => true]); foreach ($limits->items as $limit) { echo 'Type: ' . $limit->type . PHP_EOL; echo 'Limit: ' . $limit->value . PHP_EOL; echo 'Max Chars: ' . $limit->chars_limit . PHP_EOL; } // Contact details and account manager $help = $serwersms->account->help(); echo 'Phone: ' . $help->telephone . PHP_EOL; echo 'Email: ' . $help->email . PHP_EOL; echo 'Manager: ' . $help->account_maintainer->name . PHP_EOL; // Messages from administrator $msgs = $serwersms->account->messages(); if ($msgs->new) { echo 'New message: ' . $msgs->message . PHP_EOL; } // Register a new account $reg = $serwersms->account->add([ 'phone' => '+48500600700', 'email' => 'new@example.com', 'first_name' => 'John', 'last_name' => 'Doe', 'company' => 'New Company Ltd.', ]); echo 'Account registered: ' . ($reg->success ? 'yes' : 'no') . PHP_EOL; } catch (Exception $e) { echo 'ERROR: ' . $e->getMessage(); } ``` ``` -------------------------------- ### Message Templates Source: https://context7.com/serwersmspl/serwersms-laravel5/llms.txt Manage SMS message templates that can be reused when sending messages. ```APIDOC ## templates->add() / index() / edit() / delete() ### Description Manages SMS message templates that can be reused when sending messages. ### Methods - `add(string $name, string $text)`: Adds a new message template. - `index(array $options = [])`: Retrieves a list of message templates. - `edit(int $id, string $name, string $text)`: Edits an existing message template. - `delete(int $id)`: Deletes a message template. ### Request Example (Adding a template) ```php $serwersms->templates->add( 'Potwierdzenie zamówienia', 'Dziękujemy za zamówienie nr {NR}. Przewidywana dostawa: {DATA}.' ); ``` ### Response Example (Adding a template) ```json { "success": true, "id": 123 } ``` ### Request Example (Listing templates) ```php $serwersms->templates->index(['order' => 'asc']); ``` ### Response Example (Listing templates) ```json { "items": [ { "id": 1, "name": "Potwierdzenie zamówienia", "text": "Dziękujemy za zamówienie nr {NR}. Przewidywana dostawa: {DATA}." } ] } ``` ### Request Example (Editing a template) ```php $serwersms->templates->edit(123, 'Potwierdzenie zamówienia v2', 'Zamówienie {NR} przyjęte. Dostawa: {DATA}.'); ``` ### Request Example (Deleting a template) ```php $serwersms->templates->delete(123); ``` ```