### Install sMsmode Library via Composer Source: https://context7.com/webeweb/smsmode-library/llms.txt This command installs the sMsmode library using Composer, making its functionalities available in your PHP project. Ensure Composer is installed and accessible in your environment. ```bash composer require webeweb/smsmode-library ``` -------------------------------- ### Create SmsMode API Key Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Provides a step-by-step guide to creating an API key using the SmsMode library. It covers provider initialization, authentication, making the API call, and handling the response, including potential exceptions and key details. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\CreatingApiKeyRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Call the API and get the response. $response = $provider->creatingApiKey(new CreatingApiKeyRequest()); $response->getException(); // Handle the response. $response->getCode(); $response->getDescription(); $response->getId(); $response->getAccessToken(); $response->getAccount(); $response->getCreationDate(); $response->getExpiration(); $response->getState(); ``` -------------------------------- ### GET /account/balance Source: https://context7.com/webeweb/smsmode-library/llms.txt Check the current SMS credit balance of your sMsmode account. ```APIDOC ## GET /account/balance ### Description Check the current SMS credit balance of your sMsmode account. ### Method GET ### Endpoint /account/balance ### Response #### Success Response (200) - **code** (string) - API status code - **description** (string) - Status description - **accountBalance** (integer) - Current credit balance #### Response Example { "code": "0", "description": "OK", "accountBalance": 500 } ``` -------------------------------- ### Send Unicode SMS using PHP Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md This example shows how to send a Unicode SMS using the SmsMode PHP library. The process includes setting up the API provider with authentication, creating a Unicode SMS request, specifying the message and recipient numbers, and then executing the request through the API provider. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SendingUnicodeSmsRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Create a Sending unicode SMS request. $request = new SendingUnicodeSmsRequest(); $request->setMessage("message"); $request->addNumero("33600000001"); $request->addNumero("33600000002"); // ... // Call the API and get the response. $response = $provider->sendingUnicodeSMS($request); // Handle the response. $response->getCode(); $response->getDescription(); $response->getSmsID(); ``` -------------------------------- ### Retrieve SmsMode Delivery Report Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Explains how to fetch the delivery report for a specific SMS message using the SmsMode library. It covers provider setup, authentication, creating a delivery report request with an SMS ID, and iterating through the returned delivery reports. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Model\DeliveryReport; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\DeliveryReportRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Create a Delivery report request. $request = new DeliveryReportRequest(); $request->setSmsID("smsID"); // Call the API and get the response. $response = $provider->deliveryReport($request); // Handle the response. $response->getCode(); $response->getDescription(); /** @var DeliveryReport $current */ foreach($response->getDeliveryReports() as $current) { $current->getCode(); $current->getNumero(); } ``` -------------------------------- ### GET /delivery-report Source: https://context7.com/webeweb/smsmode-library/llms.txt Retrieve delivery status reports for sent SMS messages to track whether messages were delivered successfully. ```APIDOC ## GET /delivery-report ### Description Retrieve delivery status reports for sent SMS messages to track whether messages were delivered successfully. ### Method GET ### Endpoint /delivery-report ### Query Parameters - **smsID** (string) - Required - The ID of the SMS to track. ### Response #### Success Response (200) - **deliveryReports** (array) - List of reports containing numero and status code. #### Response Example { "code": 0, "deliveryReports": [ { "numero": "33600000001", "code": 0 } ] } ``` -------------------------------- ### GET /sms/list Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Retrieves a list of sent SMS messages. ```APIDOC ## GET /sms/list ### Description Retrieves the list of sent SMS messages. ### Method GET ### Endpoint /sms/list ### Response #### Success Response (200) - **smsList** (array) - List of sent messages containing smsID, sendDate, message, numero, costCredits, and recipientCount. ``` -------------------------------- ### GET /sms/status Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Checks the delivery status of a specific SMS message. ```APIDOC ## GET /sms/status ### Description Checks the status of an SMS message. ### Method GET ### Endpoint /sms/status ### Parameters #### Query Parameters - **smsID** (string) - Required - The ID of the SMS to check. ### Response #### Success Response (200) - **code** (string) - Status code. ``` -------------------------------- ### Retrieving SMS Replies Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md This endpoint allows you to retrieve SMS replies. You can specify a start and offset for pagination or use a date interval to filter replies. ```APIDOC ## Retrieving SMS Replies ### Description Retrieves SMS replies from the SMS Mode service. Supports pagination via start/offset or filtering by date range. ### Method POST ### Endpoint /api/sms/reply ### Parameters #### Query Parameters - **start** (integer) - Optional - The starting index for retrieving replies. - **offset** (integer) - Optional - The number of replies to retrieve. - **startDate** (string) - Optional - The start date for filtering replies (YYYY-MM-DD HH:MM:SS). - **endDate** (string) - Optional - The end date for filtering replies (YYYY-MM-DD HH:MM:SS). ### Request Body (No specific request body defined for this operation, parameters are typically passed via query or implicitly through provider configuration) ### Response #### Success Response (200) - **code** (integer) - The status code of the operation. - **description** (string) - A message describing the result of the operation. - **smsReplies** (array) - A list of SMS reply objects. - **responseId** (string) - The ID of the reply. - **receptionDate** (string) - The date and time the reply was received. - **from** (string) - The sender's phone number. - **text** (string) - The content of the reply. - **to** (string) - The recipient's phone number. - **messageId** (string) - The ID of the original message. #### Response Example ```json { "code": 200, "description": "Success", "smsReplies": [ { "responseId": "reply123", "receptionDate": "2023-10-27 10:00:00", "from": "+1234567890", "text": "Hello there!", "to": "+1987654321", "messageId": "msg456" } ] } ``` ``` -------------------------------- ### GET /sms/replies Source: https://context7.com/webeweb/smsmode-library/llms.txt Retrieve SMS replies from recipients with optional filtering by date range or pagination. ```APIDOC ## GET /sms/replies ### Description Retrieve SMS replies from recipients, with optional filtering by date range or pagination. ### Method GET ### Endpoint /sms/replies ### Parameters #### Query Parameters - **start** (integer) - Optional - Starting index for pagination - **offset** (integer) - Optional - Number of records to retrieve - **startDate** (datetime) - Optional - Filter replies from this date - **endDate** (datetime) - Optional - Filter replies until this date ### Request Example { "start": 0, "offset": 10 } ### Response #### Success Response (200) - **code** (string) - API status code - **description** (string) - Status description - **smsReplies** (array) - List of received SMS objects #### Response Example { "code": "0", "description": "OK", "smsReplies": [ { "responseID": "12345", "receptionDate": "2024-01-01 10:00:00", "from": "+33600000000", "to": "+33611111111", "text": "Hello", "messageID": "msg_987" } ] } ``` -------------------------------- ### Initialize API Provider with Logger Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Demonstrates how to initialize the ApiProvider with an optional PSR-3 logger and enable the debug flag for enhanced logging. This is useful for troubleshooting API interactions. ```php use Psr\Log\LoggerInterface; use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; /** @var LoggerInterface $logger */ // $logger = ... // Create the API provider. $provider = new ApiProvider(new Authentication(), $logger); $provider->setDebug(true); ``` -------------------------------- ### Adding a new contact Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Illustrates how to add a contact to the system by providing a last name and mobile number. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\AddingContactRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); $request = new AddingContactRequest(); $request->setNom("lastname"); $request->setMobile("33600000000"); $response = $provider->addingContact($request); $response->getCode(); $response->getDescription(); ``` -------------------------------- ### Transferring credits between accounts Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Shows how to transfer a specific amount of credits to a target account pseudo. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\TransferringCreditsRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); $request = new TransferringCreditsRequest(); $request->setCreditAmount(212); $request->setTargetPseudo("targetPseudo"); $response = $provider->transferringCredits($request); $response->getCode(); $response->getDescription(); ``` -------------------------------- ### Create Sub-Account - PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Creates a new sub-account under your main SMS Mode account. Requires a username and password for the new sub-account, along with an access token for authentication. Optional fields like reference and name can be set. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\CreatingSubAccountRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new CreatingSubAccountRequest(); $request->setNewPseudo("sub_account_username"); $request->setNewPass("sub_account_password"); // Optional: Set additional details // $request->setReference("dept-marketing"); // $request->setNom("Marketing Team"); $response = $provider->creatingSubAccount($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; ``` -------------------------------- ### POST /sub-account Source: https://context7.com/webeweb/smsmode-library/llms.txt Create a new sub-account under your main sMsmode account. ```APIDOC ## POST /sub-account ### Description Create a new sub-account under your main sMsmode account for organizational purposes or reselling. ### Method POST ### Endpoint /sub-account ### Parameters #### Request Body - **newPseudo** (string) - Required - Username for the sub-account - **newPass** (string) - Required - Password for the sub-account - **reference** (string) - Optional - Internal reference - **nom** (string) - Optional - Display name ### Request Example { "newPseudo": "sub_account_username", "newPass": "sub_account_password" } ### Response #### Success Response (200) - **code** (string) - API status code - **description** (string) - Status description ``` -------------------------------- ### Deleting a sub-account Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Demonstrates how to authenticate and perform a sub-account deletion request using the ApiProvider. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\DeletingSubAccountRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); $request = new DeletingSubAccountRequest(); $request->setPseudoToDelete("pseudoToDelete"); $response = $provider->deletingSubAccount($request); $response->getCode(); $response->getDescription(); ``` -------------------------------- ### SmsMode Authentication Methods Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Shows how to create an Authentication object for the SmsMode API. It supports authentication via username/password or an access token. ```php use WBW\Library\SmsMode\Model\Authentication; // Create an authentication request. $authentication = new Authentication(); // Set a couple login/password. $authentication->setPseudo("pseudo"); $authentication->setPass("pass"); // or use an access token. $authentication->setAccessToken("accessToken"); ``` -------------------------------- ### Create sMsmode API Key Source: https://context7.com/webeweb/smsmode-library/llms.txt Generates an API access token using username and password credentials. The response includes details about the created API key, such as its code, description, access token, account information, and validity period. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\CreatingApiKeyRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setPseudo("your_username"); $provider->getAuthentication()->setPass("your_password"); $response = $provider->creatingApiKey(new CreatingApiKeyRequest()); // Handle response echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; echo "Access Token: " . $response->getAccessToken() . "\n"; echo "Account: " . $response->getAccount() . "\n"; echo "Creation Date: " . $response->getCreationDate()->format('Y-m-d H:i:s') . "\n"; echo "Expiration: " . $response->getExpiration()->format('Y-m-d H:i:s') . "\n"; echo "State: " . $response->getState() . "\n"; ``` -------------------------------- ### POST /contact Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Adds a new contact to the user's address book. ```APIDOC ## POST /contact ### Description Adds a new contact. ### Method POST ### Endpoint /contact ### Parameters #### Request Body - **nom** (string) - Required - Contact last name. - **mobile** (string) - Required - Contact mobile number. ### Request Example { "nom": "lastname", "mobile": "33600000000" } ### Response #### Success Response (200) - **code** (string) - Status code. ``` -------------------------------- ### Send SMS in Batch Mode using PHP Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md This snippet demonstrates sending SMS messages in batch mode using a file with the SmsMode PHP library. It involves initializing the API provider, creating a batch SMS request, setting the file path for the batch data, and then sending the request via the API provider. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SendingSmsBatchRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Create a Sending SMS batch request. $request = new SendingSmsBatchRequest(); $request->setFichier("fichier.csv"); // Call the API and get the response. $response = $provider->sendingSMSBatch($request); // Handle the response. $response->getCode(); $response->getDescription(); $response->getCampagneID(); ``` -------------------------------- ### Configure sMsmode API Authentication Source: https://context7.com/webeweb/smsmode-library/llms.txt Sets up authentication for the sMsmode API using either username/password or an access token. The `ApiProvider` class is instantiated with the chosen authentication method. Debug mode can be enabled with an optional PSR-3 logger. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; // Method 1: Using username and password $authentication = new Authentication(); $authentication->setPseudo("your_username"); $authentication->setPass("your_password"); $provider = new ApiProvider($authentication); // Method 2: Using access token $authentication = new Authentication(); $authentication->setAccessToken("your_access_token"); $provider = new ApiProvider($authentication); // Enable debug mode with PSR-3 logger (optional) $provider->setDebug(true); // $provider = new ApiProvider($authentication, $logger); ``` -------------------------------- ### Send SMS Message with SmsMode Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Illustrates how to send an SMS message using the SmsMode library. This includes setting up the API provider, authenticating, creating the message request with recipient numbers, sending the message, and processing the response. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SendingSmsMessageRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Create a Sending SMS message request. $request = new SendingSmsMessageRequest(); $request->setMessage("message"); $request->addNumero("33600000001"); $request->addNumero("33600000002"); // ... // Call the API and get the response. $response = $provider->sendingSMSMessage($request); // Handle the response. $response->getCode(); $response->getDescription(); $response->getSmsID(); ``` -------------------------------- ### Create SmsMode Sub-Account Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Provides code to create a new sub-account within SmsMode. It details the process of setting up the API provider, authenticating, defining the new sub-account credentials, and sending the creation request. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\CreatingSubAccountRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Create a Creating sub-account request. $request = new CreatingSubAccountRequest(); $request->setNewPseudo("pseudo"); $request->setNewPass("pass"); // Call the API and get the response. $response = $provider->creatingSubAccount($request); // Handle the response. $response->getCode(); $response->getDescription(); ``` -------------------------------- ### Retrieve Delivery Report with PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Fetches the delivery status of a previously sent SMS using its unique SMS ID. Returns a list of delivery reports for each recipient. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Model\DeliveryReport; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\DeliveryReportRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new DeliveryReportRequest(); $request->setSmsID("abc123xyz"); $response = $provider->deliveryReport($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n\n"; /** @var DeliveryReport $report */ foreach ($response->getDeliveryReports() as $report) { echo "Numero: " . $report->getNumero() . "\n"; echo "Status Code: " . $report->getCode() . "\n"; echo "---\n"; } ``` -------------------------------- ### Send Text-to-Speech SMS using PHP Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md This code snippet illustrates how to send a text-to-speech SMS using the SmsMode PHP library. It involves initializing the API provider with authentication, creating a text-to-speech SMS request, setting the message content and recipient numbers, and then sending the request via the API provider. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SendingTextToSpeechSmsRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Create a Sending text-to-speech SMS request. $request = new SendingTextToSpeechSmsRequest(); $request->setMessage("message"); $request->addNumero("33600000001"); $request->addNumero("33600000002"); // ... // Call the API and get the response. $response = $provider->sendingTextToSpeechSMS($request); // Handle the response. $response->getCode(); $response->getDescription(); $response->getSmsID(); ``` -------------------------------- ### POST /sub-account/transfer Source: https://context7.com/webeweb/smsmode-library/llms.txt Transfer SMS credits from your main account to a sub-account. ```APIDOC ## POST /sub-account/transfer ### Description Transfer SMS credits from your main account to a sub-account. ### Method POST ### Endpoint /sub-account/transfer ### Parameters #### Request Body - **targetPseudo** (string) - Required - Username of the sub-account - **creditAmount** (integer) - Required - Number of credits to transfer ### Request Example { "targetPseudo": "sub_account_username", "creditAmount": 500 } ### Response #### Success Response (200) - **code** (string) - API status code - **description** (string) - Status description ``` -------------------------------- ### Check Account Balance - PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Retrieves the current SMS credit balance for your SMS Mode account. Requires an access token for authentication. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\AccountBalanceRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $response = $provider->accountBalance(new AccountBalanceRequest()); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; echo "Account Balance: " . $response->getAccountBalance() . " credits\n"; ``` -------------------------------- ### Check SmsMode Account Balance Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Demonstrates how to retrieve the current account balance from SmsMode. This involves initializing the API provider, authenticating, and making the account balance request, then accessing the balance information from the response. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\AccountBalanceRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Call the API and get the response. $response = $provider->accountBalance(new AccountBalanceRequest()); // Handle the response. $response->getCode(); $response->getDescription(); $response->getAccountBalance(); ``` -------------------------------- ### Add Contact to sMsmode Address Book (PHP) Source: https://context7.com/webeweb/smsmode-library/llms.txt This snippet demonstrates how to add a new contact to the sMsmode address book using the PHP library. It requires authentication and allows setting contact details like name, mobile number, and optionally adding them to groups, specifying a company, or setting a birth date. The response includes a code and description indicating the operation's success. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\AddingContactRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new AddingContactRequest(); $request->setNom("Doe"); $request->setPrenom("John"); $request->setMobile("33600000001"); // Optional: Add to groups $request->addGroupe("VIP Customers"); $request->addGroupe("Newsletter"); // Optional: Set company // $request->setSociete("Acme Corp"); // Optional: Set birth date // $request->setDate(new DateTime("1990-05-15")); // Optional: Other custom field // $request->setOther("Customer since 2020"); $response = $provider->addingContact($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; ``` -------------------------------- ### Retrieve SMS Replies using PHP Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md This snippet demonstrates how to retrieve SMS replies using the SmsMode PHP library. It involves creating an API provider, setting authentication credentials, constructing a retrieval request with date or offset parameters, and then iterating through the received SMS replies to access their details. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Model\SmsReply; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\RetrievingSmsReplyRequest; // Create the API provider. $provider = new ApiProvider(new Authentication()); // Set a couple login/password. $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); // or use an access token. // $provider->getAuthentication()->setAccessToken("accessToken"); // Create a Retrieving SMS reply request. $request = new RetrievingSmsReplyRequest(); $request->setStart(0); $request->setOffset(10); // or use a date interval // $request->setStartDate(new DateTime("2017-09-14 00:00:00")); // $request->setEndDate(new DateTime("2017-09-15 00:00:00")); // Call the API and get the response. $response = $provider->retrievingSMSReply($request); // Handle the response. $response->getCode(); $response->getDescription(); /** @var SmsReply $current */ foreach($response->getSMSReplies() as $current) { $current->getResponseID(); $current->getReceptionDate(); $current->getFrom(); $current->getText(); $current->getTo(); $current->getMessageID(); } ``` -------------------------------- ### Sending SMS in Batch Mode (Attached File) Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md This endpoint enables sending SMS messages in batch mode by providing a file (e.g., CSV) containing recipient information and message content. ```APIDOC ## Sending SMS in Batch Mode (Attached File) ### Description Sends multiple SMS messages efficiently by uploading a file containing the batch of messages and recipients. ### Method POST ### Endpoint /api/sms/batch ### Parameters #### Query Parameters (No specific query parameters defined for this operation) #### Request Body - **fichier** (string) - Required - The name or path of the file containing the batch SMS data (e.g., CSV format). ### Request Example ```json { "fichier": "recipients.csv" } ``` ### Response #### Success Response (200) - **code** (integer) - The status code of the operation. - **description** (string) - A message describing the result of the operation. - **campagneId** (string) - The unique identifier for the batch campaign. #### Response Example ```json { "code": 200, "description": "Batch SMS sent successfully", "campagneId": "batch_ghi789" } ``` ``` -------------------------------- ### Handle SMS Reply Callback (PHP) Source: https://context7.com/webeweb/smsmode-library/llms.txt This PHP code snippet illustrates how to process incoming SMS reply callbacks from sMsmode webhooks. It parses data such as response ID, original SMS ID, sender's number, message content, client reference, and reception date from the webhook payload (e.g., `$_POST`). The extracted information is then used to populate an `SmsReplyCallback` object. ```php use WBW\Library\SmsMode\Model\SmsReplyCallback; // Parse callback data received from sMsmode webhook // Typically from $_POST or request body $callback = new SmsReplyCallback(); $callback->setResponseID($_POST['responseID'] ?? null); $callback->setSmsID($_POST['smsID'] ?? null); $callback->setNumero($_POST['numero'] ?? null); $callback->setEmetteur($_POST['emetteur'] ?? null); $callback->setMessage($_POST['message'] ?? null); $callback->setRefClient($_POST['refClient'] ?? null); // Parse reception date if provided if (!empty($_POST['date_reception'])) { $callback->setDateReception(new DateTime($_POST['date_reception'])); } // Process the reply echo "Response ID: " . $callback->getResponseID() . "\n"; echo "Original SMS ID: " . $callback->getSmsID() . "\n"; echo "From: " . $callback->getNumero() . "\n"; echo "Sender: " . $callback->getEmetteur() . "\n"; echo "Message: " . $callback->getMessage() . "\n"; ``` -------------------------------- ### Send SMS Batch with PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Sends bulk SMS messages using a CSV file containing recipient numbers and messages. The CSV should be formatted as numero;message. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SendingSmsBatchRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new SendingSmsBatchRequest(); $request->setFichier("/path/to/recipients.csv"); $response = $provider->sendingSmsBatch($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; echo "Campaign ID: " . $response->getCampagneID() . "\n"; ``` -------------------------------- ### POST /transfer-credits Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Transfers a specified amount of credits from the current account to a target sub-account. ```APIDOC ## POST /transfer-credits ### Description Transfers credits to another account. ### Method POST ### Endpoint /transfer-credits ### Parameters #### Request Body - **creditAmount** (integer) - Required - Number of credits to transfer. - **targetPseudo** (string) - Required - The target account pseudo. ### Request Example { "creditAmount": 212, "targetPseudo": "targetPseudo" } ### Response #### Success Response (200) - **code** (string) - Status code. - **description** (string) - Status description. ``` -------------------------------- ### List Sent SMS Messages with PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Retrieves a list of previously sent SMS messages, including metadata like send date, message content, and cost in credits. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Model\SentSmsMessage; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SentSmsMessageListRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new SentSmsMessageListRequest(); $response = $provider->sentSmsMessageList($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n\n"; /** @var SentSmsMessage $sms */ foreach ($response->getSentSmsMessages() as $sms) { echo "SMS ID: " . $sms->getSmsID() . "\n"; echo "Send Date: " . $sms->getSendDate()->format('Y-m-d H:i:s') . "\n"; echo "Message: " . $sms->getMessage() . "\n"; echo "Numero: " . $sms->getNumero() . "\n"; echo "Cost (credits): " . $sms->getCostCredits() . "\n"; echo "Recipient Count: " . $sms->getRecipientCount() . "\n"; echo "---\n"; } ``` -------------------------------- ### Send Text-to-Speech SMS with PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Sends a voice message that is read aloud to specified recipients. Requires an authenticated ApiProvider and a SendingTextToSpeechSmsRequest object. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SendingTextToSpeechSmsRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new SendingTextToSpeechSmsRequest(); $request->setMessage("Your verification code is 1 2 3 4 5 6"); $request->addNumero("33600000001"); $request->addNumero("33600000002"); $response = $provider->sendingTextToSpeechSms($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; echo "SMS ID: " . $response->getSmsID() . "\n"; ``` -------------------------------- ### Retrieve SMS Replies - PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Fetches SMS replies from the SMS Mode platform. Supports filtering by date range and pagination. Requires an access token for authentication. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Model\SmsReply; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\RetrievingSmsReplyRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new RetrievingSmsReplyRequest(); // Option 1: Pagination $request->setStart(0); $request->setOffset(10); // Option 2: Date range filter // $request->setStartDate(new DateTime("2024-01-01 00:00:00")); // $request->setEndDate(new DateTime("2024-01-31 23:59:59")); $response = $provider->retrievingSmsReply($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n\n"; /** @var SmsReply $reply */ foreach ($response->getSmsReplies() as $reply) { echo "Response ID: " . $reply->getResponseID() . "\n"; echo "Reception Date: " . $reply->getReceptionDate()->format('Y-m-d H:i:s') . "\n"; echo "From: " . $reply->getFrom() . "\n"; echo "To: " . $reply->getTo() . "\n"; echo "Text: " . $reply->getText() . "\n"; echo "Original Message ID: " . $reply->getMessageID() . "\n"; echo "---\n"; } ``` -------------------------------- ### Transfer Credits - PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Transfers SMS credits from your main SMS Mode account to a specified sub-account. Requires the target sub-account's username, the amount of credits to transfer, and an access token for authentication. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\TransferringCreditsRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new TransferringCreditsRequest(); $request->setTargetPseudo("sub_account_username"); $request->setCreditAmount(500); $response = $provider->transferringCredits($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; ``` -------------------------------- ### DELETE /sub-account Source: https://context7.com/webeweb/smsmode-library/llms.txt Remove an existing sub-account from your sMsmode account. ```APIDOC ## DELETE /sub-account ### Description Remove an existing sub-account from your sMsmode account. ### Method DELETE ### Endpoint /sub-account ### Parameters #### Request Body - **pseudoToDelete** (string) - Required - Username of the sub-account to remove ### Request Example { "pseudoToDelete": "sub_account_to_remove" } ### Response #### Success Response (200) - **code** (string) - API status code - **description** (string) - Status description ``` -------------------------------- ### Handle Delivery Report Callback (PHP) Source: https://context7.com/webeweb/smsmode-library/llms.txt This PHP code snippet shows how to parse incoming delivery report callbacks from sMsmode webhooks. It extracts SMS ID, status, recipient number, client reference, and reception date from the callback data (typically from `$_POST`). The parsed data is used to populate a `DeliveryReportCallback` object for further processing. ```php use WBW\Library\SmsMode\Model\DeliveryReportCallback; // Parse callback data received from sMsmode webhook // Typically from $_POST or request body $callback = new DeliveryReportCallback(); $callback->setSmsID($_POST['smsID'] ?? null); $callback->setStatus(intval($_POST['status'] ?? 0)); $callback->setNumero($_POST['numero'] ?? null); $callback->setRefClient($_POST['refClient'] ?? null); $callback->setMccMnc(intval($_POST['mcc_mnc'] ?? 0)); // Parse reception date if provided if (!empty($_POST['date_reception'])) { $callback->setDateReception(new DateTime($_POST['date_reception'])); } // Process the callback echo "SMS ID: " . $callback->getSmsID() . "\n"; echo "Status: " . $callback->getStatus() . "\n"; echo "Numero: " . $callback->getNumero() . "\n"; echo "Reference: " . $callback->getRefClient() . "\n"; echo "MCC MNC: " . $callback->getMccMnc() . "\n"; ``` -------------------------------- ### POST /send-sms-batch Source: https://context7.com/webeweb/smsmode-library/llms.txt Sends SMS messages in bulk using a CSV file containing recipient numbers and personalized messages. ```APIDOC ## POST /send-sms-batch ### Description Sends SMS messages in bulk using a CSV file containing recipient numbers and personalized messages. ### Method POST ### Endpoint /send-sms-batch ### Request Body - **fichier** (string) - Required - Path to the CSV file (format: numero;message). - **emetteur** (string) - Optional - Sender name. - **dateEnvoi** (datetime) - Optional - Schedule date for the batch. ### Request Example { "fichier": "/path/to/recipients.csv" } ### Response #### Success Response (200) - **code** (integer) - API response code. - **description** (string) - Status description. - **campagneID** (string) - Unique identifier for the batch campaign. #### Response Example { "code": 0, "description": "OK", "campagneID": "batch_98765" } ``` -------------------------------- ### Check SMS Message Status with PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Queries the current status of a specific SMS message by its ID. Useful for verifying if a message is pending, sent, or failed. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\CheckingSmsMessageStatusRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new CheckingSmsMessageStatusRequest(); $request->setSmsID("abc123xyz"); $response = $provider->checkingSmsMessageStatus($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; ``` -------------------------------- ### Delete Sub-Account - PHP Source: https://context7.com/webeweb/smsmode-library/llms.txt Removes an existing sub-account from your SMS Mode account. Requires the username of the sub-account to be deleted and an access token for authentication. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\DeletingSubAccountRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new DeletingSubAccountRequest(); $request->setPseudoToDelete("sub_account_to_remove"); $response = $provider->deletingSubAccount($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; ``` -------------------------------- ### DELETE /sub-account Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Deletes a specific sub-account associated with the main account. ```APIDOC ## DELETE /sub-account ### Description Deletes a sub-account by its pseudo. ### Method DELETE ### Endpoint /sub-account ### Parameters #### Request Body - **pseudoToDelete** (string) - Required - The pseudo of the sub-account to delete. ### Request Example { "pseudoToDelete": "pseudoToDelete" } ### Response #### Success Response (200) - **code** (string) - API response code. - **description** (string) - API response description. ``` -------------------------------- ### Retrieving sent SMS list Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Fetches a list of sent SMS messages and iterates through the results to access message details. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Model\SentSmsMessage; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SentSmsMessageListRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); $response = $provider->sentSMSMessageList(new SentSmsMessageListRequest()); foreach($response->getSentSMSMessages() as $current) { $current->getSmsID(); $current->getSendDate(); $current->getMessage(); $current->getNumero(); $current->getCostCredits(); $current->getRecipientCount(); } ``` -------------------------------- ### Deleting an SMS Source: https://github.com/webeweb/smsmode-library/blob/master/doc/index.md Provides the implementation for deleting a specific SMS message by its ID. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\DeletingSmsRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setPseudo("pseudo"); $provider->getAuthentication()->setPass("pass"); $request = new DeletingSmsRequest(); $request->setSmsID("smsID"); $response = $provider->deletingSMS($request); $response->getCode(); $response->getDescription(); ``` -------------------------------- ### Send Standard SMS Message with sMsmode Source: https://context7.com/webeweb/smsmode-library/llms.txt Sends a standard SMS message to one or more recipients. This function allows customization of the sender ID, scheduling, delivery report notifications, message class, and client reference. Requires an access token for authentication. ```php use WBW\Library\SmsMode\Model\Authentication; use WBW\Library\SmsMode\Provider\ApiProvider; use WBW\Library\SmsMode\Request\SendingSmsMessageRequest; $provider = new ApiProvider(new Authentication()); $provider->getAuthentication()->setAccessToken("your_access_token"); $request = new SendingSmsMessageRequest(); $request->setMessage("Hello from sMsmode!"); $request->addNumero("33600000001"); $request->addNumero("33600000002"); // Optional: Set sender name (max 11 characters) $request->setEmetteur("MyApp"); // Optional: Schedule SMS for later (DateTime object) // $request->setDateEnvoi(new DateTime("2024-12-25 10:00:00")); // Optional: Set notification URL for delivery reports // $request->setNotificationUrl("https://example.com/callback"); // Optional: Set message class (1-4) // $request->setClasseMsg(4); // Optional: Set client reference // $request->setRefClient("order-12345"); $response = $provider->sendingSmsMessage($request); echo "Code: " . $response->getCode() . "\n"; echo "Description: " . $response->getDescription() . "\n"; echo "SMS ID: " . $response->getSmsID() . "\n"; ```