### Example Multiple Callback URL
Source: https://www.smsapi.pl/docs
An example of a callback URL with multiple sets of parameters for several SMS reports.
```url
https://example.com/?MsgId=613F14C4346335AE0B1DBA31%2C613F14C4346335AE0B1DBA2E%2C613F14C4346335AE0B1DBA30%2C613F14C4346335AE0B1DBA2F%2C613F14C4346335AE0B1DBA2D&donedate=1631525676%2C1631525676%2C1631525676%2C1631525676%2C1631525676&from=Test%2CTest%2CTest%2CTest%2CTest&idx=%2C%2C%2C%2C&mcc=260%2C260%2C260%2C260%2C260&mnc=3%2C3%2C3%2C3%2C3&points=0.16%2C0.16%2C0.16%2C0.16%2C0.16&sent_at=1631525676%2C1631525676%2C1631525676%2C1631525676%2C1631525676&status=403%2C403%2C403%2C403%2C403&status_name=SENT%2CSENT%2CSENT%2CSENT%2CSENT&to=48500500500%2C48500500500%2C48500500500%2C48500500500%2C48500500500&username=smsapi.user%2Csmsapi.user%2Csmsapi.user%2Cmsmsapi.user%2Csmsapi.user
```
--------------------------------
### SMIL Example
Source: https://www.smsapi.pl/docs
An example of the SMIL (Synchronized Multimedia Integration Language) format used for MMS content.
```APIDOC
## SMIL Example
### Description
This is an example of a SMIL structure used to define the content and layout of an MMS message.
### SMIL Structure
```xml
```
```
--------------------------------
### Display Blacklist using SMSAPI PHP Client
Source: https://www.smsapi.pl/docs
This example demonstrates how to retrieve your blacklist using the official SMSAPI PHP client library. Ensure you have installed the library via Composer and have your API token ready.
```php
smsapiPlService('token_api_oauth')
->blacklistFeature()
->findBlacklistedPhoneNumbers(new FindBlacklistedPhoneNumbersBag());
var_dump($blacklist);
?>
```
--------------------------------
### Example Single Callback URL
Source: https://www.smsapi.pl/docs
An example of a callback URL with a single set of parameters for a single SMS report.
```url
https://example.com/?MsgId=613F1B14346335B944450980&donedate=1631525653&from=Test&idx=1&mcc=260&mnc=3&points=0.0&sent_at=1631525653&status=403&status_name=SENT&to=48500500500&username=smsapi.user
```
--------------------------------
### Add Phone Number to Blacklist (PHP SDK)
Source: https://www.smsapi.pl/docs
This example demonstrates adding a phone number to the blacklist using the SMSAPI PHP SDK. Ensure you have the SDK installed via Composer.
```php
smsapiPlService('token_api_oauth')
->blacklistFeature()
->createBlacklistedPhoneNumber(new CreateBlacklistedPhoneNumberBag('48500000000'));
var_dump($blacklist);
?>
```
--------------------------------
### Send VMS Message using SMSAPI PHP Client
Source: https://www.smsapi.pl/docs
This example shows how to send a VMS message using the official SMSAPI PHP client library. Ensure you have installed the library via Composer and replaced the placeholder token.
```php
smsapiPlService('token_api_oauth')
->vmsFeature()
->sendVms(new SendVmsBag('48500000000', 'Hello world!'));
var_dump($vms);
```
--------------------------------
### Assign Contact to Group using SMSAPI SDK (PHP)
Source: https://www.smsapi.pl/docs
This example demonstrates assigning a contact to a group using the SMSAPI PHP SDK. Ensure you have the SDK installed via Composer. It requires your API token and the IDs of the contact and group.
```php
smsapiPlService('token_api_oauth')
->contactsFeature()
->groupsFeature()
->assignContactToGroup(new AssignContactToGroupBag('contact_id', 'group_id'));
var_dump($contact);
?>
```
--------------------------------
### HLR Callback Data Example
Source: https://www.smsapi.pl/docs
This example shows the structure of data sent to a callback URL when an HLR check is completed. It includes details like ID, number, network information, and status.
```php
Array
(
[0] => Array
(
[id] => 80625
[number] => 48600600600
[mcc] => 260
[mnc] => 2
[info] => T-Mobile
[status] => OK
[date] => 1302703609
[ported] => 0
[ported_from] => null
)
[1] => Array
(
[id] => 80627
[number] => 48500600700
[mcc] => 260
[mnc] => 2
[info] => ABSENT_SUBSCRIBER
[status] => FAIL
[date] => 1302703609
[ported] => 0
[ported_from] => null
)
)
```
--------------------------------
### API Authorization Header Example
Source: https://www.smsapi.pl/docs
This example demonstrates the required Authorization header for API requests using OAuth 2.0 Bearer token. Ensure your token is valid and has the necessary permissions.
```http
POST /sms.do HTTP/1.1
Host: https://api.smsapi.pl/
Authorization: Bearer token_api_oauth
```
--------------------------------
### Initiate OAuth2 Authorization (Step 1)
Source: https://www.smsapi.pl/docs
Redirect the user to this URL to start the authorization process. The user will log in and approve the integration. Ensure your redirect_uri is correctly configured.
```url
https://ssl.smsapi.pl/oauth/access?client_id=123456&redirect_uri=https://www.sample.pl/&scope=sms mms hlr
```
--------------------------------
### Example Success Response for Adding Contact
Source: https://www.smsapi.pl/docs
This is an example of a successful JSON response when adding a contact via the SMSAPI. It includes the contact's ID and details.
```json
{
"id":"5b802315a788494a04690d1d",
"first_name":"string",
"last_name":"string",
"phone_number":"48500000000",
"email":"bok@smsapi.pl",
"gender":"płeć",
"city":"miasto",
"date_created":"2018-08-24T17:24:05+02:00",
"date_updated":"2018-08-24T17:24:05+02:00",
"description":"opis",
"groups":
[
{
"id":"59a3ca1fa78849062837cd0c",
"name":"default",
"date_created":"2017-08-28T09:45:35+02:00",
"date_updated":"2017-08-28T09:45:35+02:00",
"description":"",
"created_by":"username",
"idx":null,
"contact_expire_after":null,
"contacts_count":null
}
]
}
```
--------------------------------
### Send SMS with Discount Code (Java SDK)
Source: https://www.smsapi.pl/docs
Example of sending an SMS with a discount code using the SMSAPI Java SDK.
```APIDOC
## Send SMS with Discount Code (Java SDK)
### Description
This Java code demonstrates how to send an SMS message with a discount code using the SMSAPI Java SDK. It includes setting the OAuth token, proxy, and specifying the recipients and message content, including the discount code placeholder.
### Method
SDK Method
### Endpoint
N/A (SDK)
### Parameters
- **oauthToken** (string) - Your API OAuth token.
- **to** (array of strings) - An array of recipient phone numbers.
- **message** (string) - The message content. Use `[%code%]` as a placeholder for the discount code.
- **discountGroup** (string) - The name of the discount group to use.
### Request Example
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.SmsFactory;
import pl.smsapi.api.action.sms.SMSSend;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class SendSmssWithDiscountCode {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
SmsFactory smsApi = new SmsFactory(client, proxy);
String[] to = {"000000000", "000000001"};
SMSSend action = smsApi.actionSend(to, "Hello world! Discount code: [%code%]");
action.setDiscountGroup("codes");
action.execute();
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
### Response
#### Success Response
The `execute()` method sends the SMS. Successful execution does not return specific data but indicates no exception was thrown.
#### Response Example
```java
// No specific return value for success, exceptions indicate errors.
```
```
--------------------------------
### Add Contact via PHP (SMSAPI Client Library)
Source: https://www.smsapi.pl/docs
This PHP example uses the SMSAPI client library to create a contact. It requires the 'smsapi/smsapi-client' package and an OAuth token.
```php
smsapiPlService('token_api_oauth')
->contactsFeature()
->createContact(CreateContactBag::withEmail('example@example.com'));
var_dump($contact);
?>
```
--------------------------------
### Send SMS with Discount Code (Python SDK)
Source: https://www.smsapi.pl/docs
Example of sending an SMS with a discount code using the SMSAPI Python client library.
```APIDOC
## Send SMS with Discount Code (Python SDK)
### Description
This Python code snippet shows how to send an SMS message with a discount code using the SMSAPI Python client. It allows specifying recipients, message content, and sender ID.
### Method
SDK Method
### Endpoint
N/A (SDK)
### Parameters
- **access_token** (string) - Your SMSAPI access token.
- **to** (string) - Recipient phone number(s), comma-separated.
- **message** (string) - The message content. Use `[%kod%]` as a placeholder for the discount code.
- **from_** (string) - Sender ID. Must be pre-configured.
### Request Example
```python
from smsapi.client import Client
client = Client("https://api.smsapi.pl/", access_token="%SMSAPI_ACCESS_TOKEN%")
send_results = client.sms.send(to="48500000000,48500000001,48500000002", message="treść wiadomości kod rabatowy: [%kod%]", from_="Pole nadawcy")
for result in send_results:
print(result.id, result.points, result.error)
```
### Response
#### Success Response
An iterable of result objects, each containing `id`, `points`, and `error` for the sent SMS.
#### Response Example
```python
# Example output for each result object:
# ('12345', 1, None)
```
```
--------------------------------
### Send SMS with Discount Code (PHP SDK)
Source: https://www.smsapi.pl/docs
Example of sending an SMS with a discount code using the SMSAPI PHP client library.
```APIDOC
## Send SMS with Discount Code (PHP SDK)
### Description
This PHP code snippet demonstrates how to send an SMS message containing a discount code using the SMSAPI SDK. It utilizes the `SendSmssBag` to construct the message and specify recipients.
### Method
SDK Method
### Endpoint
N/A (SDK)
### Parameters
- **oauth_token** (string) - Your API OAuth token.
- **recipients** (array of strings) - An array of phone numbers to send the SMS to.
- **message** (string) - The message content. Use `[%kod%]` as a placeholder for the discount code.
### Request Example
```php
smsapiPlService('token_api_oauth')
->smsFeature()
->sendSmss(SendSmssBag::withMessage(['48500000000', '48500000001'], 'Hello world! Discount code: [%kod%]'));
var_dump($smss);
?>
```
### Response
#### Success Response
An array of `Sms` objects, each containing details about the sent SMS.
#### Response Example
```php
Sms { ... },
// 1 => Sms { ... }
// )
?>
```
```
--------------------------------
### Fetch Contacts using SMSAPI PHP Client
Source: https://www.smsapi.pl/docs
This example demonstrates fetching contacts using the official SMSAPI PHP client library. It requires the 'smsapi/smsapi-client' package and an OAuth token.
```php
phoneNumber = 48500000000;
/** @var Contact[] $contacts */
$contacts = (new SmsapiHttpClient())
->smsapiPlService('token_api_oauth')
->contactsFeature()
->findContacts($findContactsBag);
var_dump($contacts);
```
--------------------------------
### Blacklist Success Response Example
Source: https://www.smsapi.pl/docs
This is an example of a successful response when retrieving the blacklist. It shows the structure of the data returned for each blacklisted phone number, including ID, phone number, creation date, and expiration date.
```json
[{
"id":"ID_wpisu",
"phone_number":"48500000000",
"created_at":"2018-11-08T09:36:53+01:00",
"expire_at":"2021-03-16"
},
{
"id":"ID_wpisu",
"phone_number":"48500000001",
"created_at":"2018-11-08T09:36:53+01:00",
"expire_at":null
}]
```
--------------------------------
### Example Success Response for Sender List
Source: https://www.smsapi.pl/docs
A successful response containing a collection of sender names and the total size.
```json
{
"collection":[
{
"sender":"pole_nadawcy1",
"is_default":false,
"status":"ACTIVE",
"created_at":"2018-09-23T12:00:00+02:00"
},
{
"sender":"pole_nadawcy2",
"is_default":true,
"status":"ACTIVE",
"created_at":"2019-05-19T16:00:00+02:00"
},
{
"sender":"pole_nadawcy3",
"is_default":false,
"status":"INACTIVE",
"created_at":"2020-01-01T00:30:00+02:00"
}
],
"size":3
}
```
--------------------------------
### Send SMS with idz.do Link (PHP - Basic)
Source: https://www.smsapi.pl/docs
Basic PHP example for sending an SMS message with an idz.do shortened link.
```APIDOC
## Send SMS with idz.do Link (PHP - Basic)
### Description
Sends an SMS message with an idz.do shortened link using PHP.
### Parameters
- **to** (string) - Required - Recipient phone number(s), comma-separated.
- **from** (string) - Required - Sender ID.
- **message** (string) - Required - Message content, including the idz.do link format `[%idzdo:url%]`.
- **format** (string) - Required - Response format, e.g., `json`.
```
--------------------------------
### Send SMS using Python SDK
Source: https://www.smsapi.pl/docs
This example demonstrates sending a single SMS message using the Python SDK for SMSAPI.
```python
from smsapi.client import Client
client = Client("https://api.smsapi.pl/", access_token="%SMSAPI_ACCESS_TOKEN%")
send_results = client.sms.send(to="48500000000", message="treść wiadomości", from_="Pole Nadawcy")
for result in send_results:
print(result.id, result.points, result.error)
```
--------------------------------
### Send SMS using Java SDK
Source: https://www.smsapi.pl/docs
This example shows how to send a single SMS message using the Java SDK for SMSAPI.
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.SmsFactory;
import pl.smsapi.api.action.sms.SMSSend;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class SendSms {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
SmsFactory smsApi = new SmsFactory(client, proxy);
SMSSend action = smsApi.actionSend("000000000", "test message");
action.execute();
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
--------------------------------
### Send SMS using PHP SDK
Source: https://www.smsapi.pl/docs
This example shows how to send a single SMS message using the official PHP SDK for SMSAPI.
```php
smsapiPlService('token_api_oauth')
->smsFeature()
->sendSms(SendSmsBag::withMessage('48500000000', 'Hello world!'));
var_dump($sms);
?>
```
--------------------------------
### Send MMS using Python SDK
Source: https://www.smsapi.pl/docs
Example of sending an MMS message using the SMSAPI Python SDK.
```APIDOC
## Send MMS with Python SDK
### Description
This code snippet demonstrates how to send an MMS message using the SMSAPI Python client library.
### Code Example
```python
from smsapi.client import Client
client = Client("https://api.smsapi.pl/", access_token="%SMSAPI_ACCESS_TOKEN%")
def basic_send_mms():
client.mms.send(to='48500000000', subject='Temat Wiadomości', \
smil='
')
```
```
--------------------------------
### Send MMS using Java SDK
Source: https://www.smsapi.pl/docs
Example of sending an MMS message using the SMSAPI Java SDK.
```APIDOC
## Send MMS with Java SDK
### Description
This code snippet demonstrates how to send an MMS message using the SMSAPI Java SDK.
### Code Example
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.MmsFactory;
import pl.smsapi.api.action.mms.MMSSend;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class SendMms {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
MmsFactory mmsApi = new MmsFactory(client, proxy);
MMSSend action = mmsApi.actionSend("000000000", "...");
action.execute();
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
```
--------------------------------
### Successful Subuser Update Response
Source: https://www.smsapi.pl/docs
This is an example of a successful JSON response when updating a subuser. It includes the subuser's ID, username, activity status, description, and point allocation details.
```json
{
"id":"5A8D6E6F373830607C87B277",
"username":"Subuser name",
"active":true,
"description":"Opis",
"points":{
"from_account":2,
"per_month":2
}
}
```
--------------------------------
### Step 1: Initiate Authorization Request
Source: https://www.smsapi.pl/docs
This step involves redirecting the user to SMSAPI to log in and authorize the integration. The user's browser will be redirected back to the specified redirect_uri with an authorization code.
```APIDOC
## GET https://ssl.smsapi.pl/oauth/access/
### Description
Initiates the PKCE authorization flow by redirecting the user to SMSAPI for login and consent.
### Method
GET
### Endpoint
https://ssl.smsapi.pl/oauth/access/
### Parameters
#### Query Parameters
- **client_id** (string) - Required - Unique ID for the application.
- **redirect_uri** (string) - Required - The URL to which the user will be redirected after authorization.
- **code_challenge** (string) - Required - A transformed version of the code_verifier, generated using SHA256 and Base64 URL encoding.
- **code_challenge_method** (string) - Required - The method used for generating the code_challenge. Should always be 'S256'.
- **scope** (string) - Required - Defines the permissions for the integration.
- **state** (string) - Optional - A CSRF protection token.
### Request Example
```
https://ssl.smsapi.pl/oauth/access?client_id=123456&redirect_uri=https://www.sample.pl/&code_challenge=12345678&code_challenge_method=S256&scope=sms
```
### Response
#### Redirect
Upon successful user authorization, the user is redirected to the `redirect_uri` with a `code` query parameter.
#### Response Example
```
https://www.sample.pl/?code=11112222
```
```
--------------------------------
### First Step of PKCE Authorization
Source: https://www.smsapi.pl/docs
Initiates the PKCE authorization flow by redirecting the user to SMSAPI for login and integration approval. Requires client_id, redirect_uri, and a generated code_challenge.
```http
https://ssl.smsapi.pl/oauth/access?client_id=123456&redirect_uri=https://www.sample.pl/&code_challenge=12345678&code_challenge_method=S256&scope=sms
```
--------------------------------
### Listowanie użytkowników za pomocą PHP (SDK)
Source: https://www.smsapi.pl/docs
Wykorzystuje SDK PHP do listowania użytkowników. Wymaga zainstalowania zależności przez Composer i podania tokenu API OAuth.
```php
smsapiPlService('token_api_oauth')
->subusersFeature()
->findSubusers();
var_dump($subusers);
```
--------------------------------
### Add Subuser via SMSAPI PHP Client
Source: https://www.smsapi.pl/docs
This example demonstrates adding a subuser using the official SMSAPI PHP client library. It requires the 'vendor/autoload.php' to be included and uses the SmsapiHttpClient to interact with the API.
```php
smsapiPlService('token_api_oauth')
->subusersFeature()
->createSubuser(new CreateSubuserBag('username', 'password'));
var_dump($subuser);
?>
```
--------------------------------
### Blacklist Failure Response Example
Source: https://www.smsapi.pl/docs
This is an example of an error response when an issue occurs during a blacklist retrieval request. It typically indicates an authorization failure.
```json
{
"error": 101,
"message": "authorization_failed"
}
```
--------------------------------
### Successful Contacts API Response Example
Source: https://www.smsapi.pl/docs
This is an example of a successful JSON response when fetching contacts from the SMSAPI. It includes details about the contact and their groups.
```json
{
"size":1,
"collection":[
{
"id":"5b83ba81a788494a0469490f",
"first_name":"Imię",
"last_name":"Nazwisko",
"birthday_date": "1998-03-09",
"phone_number":"48500000000",
"email":"bok@smsapi.pl",
"gender":"male",
"city":"Miasto",
"country":"Poland",
"source":"source",
"date_created":"2018-08-27T10:46:57+02:00",
"date_updated":"2018-08-27T10:46:57+02:00",
"groups":[
{
"id":"59a3ca1fa78849062837cd0c",
"name":"default",
"date_created":"2017-08-28T09:45:35+02:00",
"date_updated":"2017-08-28T09:45:35+02:00",
"description":"",
"created_by":"login",
"idx":null,
"contact_expire_after":null,
"contacts_count":null
}
]
}
]
}
```
--------------------------------
### Failed Contacts API Response Example
Source: https://www.smsapi.pl/docs
This is an example of a JSON response indicating an authorization failure when interacting with the SMSAPI. It includes an error message and code.
```json
{
"message":"Authorization failed",
"error":"authorization_failed",
"errors":null
}
```
--------------------------------
### Add Contact via Java (SMSAPI Client Library)
Source: https://www.smsapi.pl/docs
This Java example shows how to add a contact using the SMSAPI client library. It requires an OAuth token and specifies the email address for the new contact.
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.action.contacts.ContactAdd;
import pl.smsapi.api.action.contacts.ContactsFactory;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class AddContact {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
ContactsFactory contactsApi = new ContactsFactory(client, proxy);
ContactAdd action = contactsApi.actionAdd();
action.withEmail("example@example.com");
action.execute();
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
--------------------------------
### Example SMIL Message Structure
Source: https://www.smsapi.pl/docs
This is an example of a SMIL (Synchronized Multimedia Integration Language) structure for an MMS message. It defines regions for images and text, and specifies the content sources.
```xml
```
--------------------------------
### Verify SSL Certificate with wget
Source: https://www.smsapi.pl/docs
Use wget to test the SSL certificate by making a request to the test URL. A successful connection will return 'OK'.
```bash
$ wget -qO- https://certificate-test.smsapi.com/
```
--------------------------------
### Blacklist API Response Examples
Source: https://www.smsapi.pl/docs
These are example responses for adding a phone number to the blacklist. The success response includes details of the added entry, while the failure response indicates an error code and message.
```json
{
"id":"ID_wpisu",
"phone_number":"48500000000",
"created_at":"2018-11-08T09:36:53+01:00",
"expire_at":"2021-03-16"
}
```
```json
{
"error": 101,
"message": "authorization_failed"
}
```
--------------------------------
### Listowanie użytkowników za pomocą Java (SDK)
Source: https://www.smsapi.pl/docs
Przykład użycia SDK Java do listowania użytkowników. Wymaga podania tokenu API OAuth i adresu API.
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.action.subusers.Subusers;
import pl.smsapi.api.action.subusers.SubusersFactory;
import pl.smsapi.api.action.subusers.SubusersList;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class ListSubusers {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
SubusersFactory subusersApi = new SubusersFactory(client, proxy);
SubusersList action = subusersApi.actionList();
Subusers subusers = action.execute();
subusers.list.forEach(subuser -> System.out.println(subuser.username));
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
--------------------------------
### Send SMS with Discount Code (HTTP)
Source: https://www.smsapi.pl/docs
This example shows how to send an SMS message with a discount code using a direct HTTP POST request. Ensure your discount group is active and contains available codes.
```APIDOC
## POST https://api.smsapi.pl/sms.do
### Description
Sends an SMS message with a discount code. The system automatically assigns an available discount code from the specified group to each recipient.
### Method
POST
### Endpoint
https://api.smsapi.pl/sms.do
### Parameters
#### Query Parameters
- **from** (string) - Required - Sender ID. Must be pre-configured.
- **to** (string) - Required - Recipient phone number(s), comma-separated.
- **discount_group** (string) - Required - The name of the discount group to use for generating codes.
- **message** (string) - Required - The message content. Use `[%kod%]` as a placeholder for the discount code.
- **format** (string) - Required - Response format, e.g., `json`.
### Request Example
```json
{
"example": "curl -X POST -H \"Authorization: Bearer token_api_oauth\" \"https://api.smsapi.pl/sms.do?from=pole_nadawcy&to=48600111222,48500111222&discount_group=kody&message=Test_wiadomości_z_kodem_rabatowym_[%kod%]&format=json\""
}
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the status of the request.
- **id** (string) - Unique identifier for the sent SMS.
- **points** (number) - Number of points deducted for sending the SMS.
#### Response Example
```json
{
"example": "{\"status\":\"success\", \"id\":\"12345\", \"points\":1}"
}
```
```
--------------------------------
### Send SMS with Opt-Out Link using Java
Source: https://www.smsapi.pl/docs
This Java example demonstrates sending an SMS with an opt-out link using the SMSAPI Java library. It includes setting up the OAuth client and executing the send action.
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.SmsFactory;
import pl.smsapi.api.action.sms.SMSSend;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class SendSmssWithOptOut {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
SmsFactory smsApi = new SmsFactory(client, proxy);
String[] to = {"000000000", "000000001"};
SMSSend action = smsApi.actionSend(to, "Hello world! Go: [%opt_out_link%]");
action.execute();
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
--------------------------------
### Get Contacts
Source: https://www.smsapi.pl/docs
Retrieves a list of contacts. Supports filtering by various parameters.
```APIDOC
## GET https://api.smsapi.pl/contacts
### Description
Retrieves a list of contacts. Supports filtering by various parameters such as birthday_date, phone_number, and custom fields.
### Method
GET
### Endpoint
https://api.smsapi.pl/contacts
### Parameters
#### Query Parameters
- **birthday_date** (string) - Optional - Filters contacts by birthday date. Example: `between(YYYY-MM-DD,YYYY-MM-DD)`
- **phone_number** (string) - Optional - Filters contacts by phone number.
- **Pole_dodatkowe** (string) - Optional - Filters contacts by a custom field. Can use `between(value1,value2)` for range filtering.
```
```shell
curl -X GET -H "Authorization: Bearer token_api_oauth" https://api.smsapi.pl/contacts?birthday_date=between%281997-02-24%2C%202002-02-24%29
```
```php
```
```php
phoneNumber = 48500000000;
/** @var Contact[] $contacts */
$contacts = (new SmsapiHttpClient())
->smsapiPlService('token_api_oauth')
->contactsFeature()
->findContacts($findContactsBag);
var_dump($contacts);
```
```python
from smsapi.client import Client
client = Client("https://api.smsapi.pl", access_token="%SMSAPI_ACCESS_TOKEN%")
def get_all_contacts():
l = client.contacts.list_contacts()
for c in l:
print(c.id, c.first_name, c.last_name, c.phone_number)
```
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.action.contacts.Contacts;
import pl.smsapi.api.action.contacts.ContactsFactory;
import pl.smsapi.api.action.contacts.ContactsList;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class ListContacts {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
ContactsFactory contactsApi = new ContactsFactory(client, proxy);
ContactsList action = contactsApi.actionList();
action.filterByPhoneNumber("48500000000");
Contacts contacts = action.execute();
contacts.list.forEach(contact -> System.out.println(contact.email));
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
--------------------------------
### List Contacts using SMSAPI Java Client
Source: https://www.smsapi.pl/docs
This Java example demonstrates listing contacts and filtering by phone number using the SMSAPI Java client library. Ensure you replace the placeholder token with your actual OAuth token.
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.action.contacts.Contacts;
import pl.smsapi.api.action.contacts.ContactsFactory;
import pl.smsapi.api.action.contacts.ContactsList;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
public class ListContacts {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
ContactsFactory contactsApi = new ContactsFactory(client, proxy);
ContactsList action = contactsApi.actionList();
action.filterByPhoneNumber("48500000000");
Contacts contacts = action.execute();
contacts.list.forEach(contact -> System.out.println(contact.email));
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
}
}
}
```
--------------------------------
### Example Failure Response for Sender Status
Source: https://www.smsapi.pl/docs
An error response when a sender name is not found.
```json
{
"message":"Sendername not exists",
"error":"not_found_sendername",
"errors":[
{
"error":"not_found_sendername",
"message":"Sendername not exists"
}]
}
```
--------------------------------
### Get Contacts
Source: https://www.smsapi.pl/docs
Retrieves contacts from the SMSAPI. This endpoint allows for secure SSL connections.
```APIDOC
## GET https://api.smsapi.pl/contacts
### Description
Retrieves contacts from the SMSAPI. This endpoint supports secure SSL connections.
### Method
GET
### Endpoint
https://api.smsapi.pl/contacts
```
--------------------------------
### Example Success Response for Sender Status
Source: https://www.smsapi.pl/docs
A successful response when checking a sender name's status.
```json
{
"sender":"pole_nadawcy",
"is_default":false,
"status":"ACTIVE",
"created_at":"2020-01-01T00:00:00+02:00"
}
```
--------------------------------
### Send VMS via POST request (Audio File)
Source: https://www.smsapi.pl/docs
This snippet demonstrates how to send a VMS message using an audio file via a POST request.
```APIDOC
## POST /vms.do
### Description
Sends a Voice Message Service (VMS) message using a pre-recorded audio file.
### Method
POST
### Endpoint
https://api.smsapi.pl/vms.do
### Parameters
#### Query Parameters
- **to** (string) - Required - Recipient's phone number.
- **file** (string) - Required - URL to the audio file (e.g., WAV format).
- **format** (string) - Optional - The format of the response (e.g., json).
### Request Example
```curl
curl -X POST -H "Authorization: Bearer token_api_oauth" \
"https://api.smsapi.pl/vms.do?\
to=48500000000&\
file=http://hiper.lacze.do/pliku.wav&\
format=json"
```
### Response
#### Success Response (200)
- **count** (integer) - Number of messages processed.
- **list** (array) - List of message details.
- **id** (string) - Unique message ID.
- **points** (integer) - Points consumed for the message.
- **number** (string) - Recipient's phone number.
- **date_sent** (integer) - Timestamp when the message was sent.
- **submitted_number** (string) - The number submitted for sending.
- **status** (string) - Status of the message (e.g., QUEUE).
- **error** (null) - Error code, null if successful.
- **idx** (null) - Index, null if not applicable.
#### Response Example (Success)
```json
{
"count":1,
"list":[
{
"id":"0006759312242528650",
"points":1,
"number":"48500000000",
"date_sent":1535100067,
"submitted_number":"48500000000",
"status":"QUEUE",
"error":null,
"idx":null
}
]
}
```
#### Error Response
- **error** (integer) - Error code.
- **message** (string) - Error description.
#### Response Example (Error)
```json
{
"error":23,
"message":"Remote get error: http:\/\/hiper.lacze.do\/pliku.wav"
}
```
```
```python
from smsapi.client import Client
client = Client("https://api.smsapi.pl", access_token="%SMSAPI_ACCESS_TOKEN%")
def send_vms_from_file():
client.vms.send_flash(to='some-number', file='/path/to/vms/file')
```
```java
import pl.smsapi.OAuthClient;
import pl.smsapi.api.VmsFactory;
import pl.smsapi.api.action.vms.VMSSend;
import pl.smsapi.exception.SmsapiException;
import pl.smsapi.proxy.ProxyNative;
import java.io.File;
import java.io.IOException;
public class SendVmsFromFile {
public static void main(String[] args) {
try {
String oauthToken = "00000000000000000000000000000000";
OAuthClient client = new OAuthClient(oauthToken);
ProxyNative proxy = new ProxyNative("https://api.smsapi.pl/");
VmsFactory vmsApi = new VmsFactory(client, proxy);
VMSSend action = vmsApi.actionSend("000000000", new File("/path/to/vms/file"));
action.execute();
} catch (SmsapiException e) {
System.out.println("Exception: " + e.getMessage());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
```