PHPackages                             infobip-community/infobip-api-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. infobip-community/infobip-api-php-sdk

ActiveLibrary[API Development](/categories/api)

infobip-community/infobip-api-php-sdk
=====================================

PHP SDK package for Infobip API

v1.1.0(4y ago)614.8k↓13.6%4[3 issues](https://github.com/infobip-community/infobip-api-php-sdk/issues)[2 PRs](https://github.com/infobip-community/infobip-api-php-sdk/pulls)MITPHPPHP ^7.2.5 || ^8.0CI failing

Since Mar 1Pushed 12mo ago2 watchersCompare

[ Source](https://github.com/infobip-community/infobip-api-php-sdk)[ Packagist](https://packagist.org/packages/infobip-community/infobip-api-php-sdk)[ Docs](https://github.com/infobip-community/infobip-api-php-sdk)[ RSS](/packages/infobip-community-infobip-api-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (13)Versions (3)Used By (0)

⚠️ Deprecated
-------------

[](#️-deprecated)

**This repository is deprecated and no longer actively maintained, it will be archived in the near future.**

If you're looking for an active alternative, we recommend using [infobip-api-php-client](https://github.com/infobip/infobip-api-php-client) instead.

You’re still welcome to browse or fork the code, but issues and pull requests will not be monitored.

Infobip API PHP SDK
===================

[](#infobip-api-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/799b66c14e0ad20d4da745b9f263ebd48e0f404e2857111b506efcae7bcaa125/68747470733a2f2f706f7365722e707567782e6f72672f696e666f6269702d636f6d6d756e6974792f696e666f6269702d6170692d7068702d73646b2f762f737461626c65)](https://packagist.org/packages/infobip-community/infobip-api-php-sdk)[![Latest Unstable Version](https://camo.githubusercontent.com/b58d10aa8cf2681512b67ed2dccd9c54fb9eea0f0b982ade11ba5b82b365366a/68747470733a2f2f706f7365722e707567782e6f72672f696e666f6269702d636f6d6d756e6974792f696e666f6269702d6170692d7068702d73646b2f762f756e737461626c65)](https://packagist.org/packages/infobip-community/infobip-api-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/744b0bb742f3c52ddcba790d6ea436f457db1d9396c7db36053029bc113de2d6/68747470733a2f2f706f7365722e707567782e6f72672f696e666f6269702d636f6d6d756e6974792f696e666f6269702d6170692d7068702d73646b2f646f776e6c6f616473)](https://packagist.org/packages/infobip-community/infobip-api-php-sdk/stats)[![License](https://camo.githubusercontent.com/490b8bb6291e5d334ac10e2fa4dc348f71a8a4f0cb876605ffe1cfacbe3f7431/68747470733a2f2f706f7365722e707567782e6f72672f696e666f6269702d636f6d6d756e6974792f696e666f6269702d6170692d7068702d73646b2f6c6963656e7365)](LICENSE)

This is a PHP SDK for Infobip API and you can use it as a dependency to add [Infobip APIs](https://www.infobip.com/docs/api) to your application. To use this, you'll need an Infobip account. If you do not own one, you can create a [free account here](https://www.infobip.com/signup).

#### Table of contents:

[](#table-of-contents)

- [General Info](#general-info)
- [License](#license)
- [Compatibility Chart](#compatibility-chart)
- [Installation](#installation)
- [Basic usage](#basic-usage)
    - [Example](#example)
    - [Exceptions](#exceptions)
    - [Laravel](#laravel)
    - [Symfony](#symfony)
- [Documentation](#documentation)
- [Development](#development)

General Info
------------

[](#general-info)

For `infobip-api-php-sdk` versioning we use [Semantic Versioning](https://semver.org) scheme.

License
-------

[](#license)

Published under [MIT License](LICENSE).

Compatibility Chart
-------------------

[](#compatibility-chart)

Infobip API PHP SDKPHP1.\*7.2.5+ / 8+Installation
------------

[](#installation)

To start using the `infobip-api-php-sdk` library add it as dependency to your `composer.json` project dependency:

```
composer require infobip-community/infobip-api-php-sdk
```

Or you can add it manually to `composer.json` file:

```
"require": {
    "infobip-community/infobip-api-php-sdk": "1.*"
}
```

And then simply run `composer install` to download dependencies.

Basic usage
-----------

[](#basic-usage)

Example on how to create the `InfobipClient` instance. You can also define it in your DI Container and get configuration data from the `env()` or configuration file.

```
$infobipClient = new Infobip\InfobipClient(
    'apiKey',
    'baseUrl',
    3 // timeout in seconds, optional parameter
);
```

### Example

[](#example)

A simple example of using the `InfobipClient` for calling the :

```
// example 1
$resource = new \Infobip\Resources\WhatsApp\WhatsAppTextMessageResource(
    '441134960000',
    '441134960001',
    new \Infobip\Resources\WhatsApp\Models\TextContent('text message')
);

$response = $infobipClient
    ->whatsApp()
    ->sendWhatsAppTextMessage($resource);
```

### Exceptions

[](#exceptions)

There is a couple of Infobip `exceptions` that you could stumble upon while using the `InfobipClient`:

- Bad request (400)
- Unauthorized (401)
- Forbidden (403)
- Not found (404)
- Unprocessable entity (422)
- Too many requests (429)
- Internal server error (500)

Of course, there is a way of handling those:

```
try {
    $resource = new WhatsAppTextMessageResource();

    $response = $infobipClient
        ->whatsApp()
        ->sendWhatsAppTextMessage($resource);
} catch (InfobipException $exception) {
    $exception->getMessage(); // error message
    $exception->getCode(); // http status code
    $exception->getValidationErrors(); // array of validation errors, only available on 400 Bad request and 422 Unprocessable entity exceptions
}
```

### Laravel

[](#laravel)

Register the `InfobipServiceProvider` in your `config/app.php` configuration file:

```
'providers' => [
    // Application Service Providers...
    // ...

    // Other Service Providers...
    Infobip\Support\Laravel\InfobipServiceProvider::class,
    // ...
],
```

And then run the following command to copy the Infobip configuration file to your `config` directory:

```
php artisan vendor:publish --provider="Infobip\Support\Laravel\InfobipServiceProvider"
```

After that, you can start using the Infobip API PHP SDK package in your Laravel project, just inject the `InfobipClient` into your codebase:

```
