PHPackages                             jaime/whatsapp-gupshup - 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. jaime/whatsapp-gupshup

ActiveLibrary[API Development](/categories/api)

jaime/whatsapp-gupshup
======================

Libreria WhatsApp Gupshup PHP

84.5k4PHP

Since Nov 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jaimey/Whatsapp-Gupshup-Library-PHP)[ Packagist](https://packagist.org/packages/jaime/whatsapp-gupshup)[ RSS](/packages/jaime-whatsapp-gupshup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Libreria WhatsApp Gupshup PHP
=============================

[](#libreria-whatsapp-gupshup-php)

- [Libreria WhatsApp Gupshup PHP](#libreria-whatsapp-gupshup-php)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Outbound Message](#outbound-message)
            - [Send Text](#send-text)
            - [Send Image](#send-image)
            - [Send Audio](#send-audio)
            - [Send File](#send-file)
            - [Send Video](#send-video)
            - [Send Sticker](#send-sticker)
            - [Send List Messages](#send-list-messages)
            - [Send Quick replies](#send-quick-replies)
            - [Send Quick Replies Text](#send-quick-replies-text)
            - [Get Template list](#get-template-list)
            - [Send a message through a template](#send-a-message-through-a-template)
            - [Get Opt-in User list](#get-opt-in-user-list)
            - [Mark User Opt-in Opt-out](#mark-user-opt-in-opt-out)
            - [Check Wallet balance](#check-wallet-balance)
        - [Inbound Message and Events](#inbound-message-and-events)
    - [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require jaime/whatsapp-gupshup
```

Usage
-----

[](#usage)

### Outbound Message

[](#outbound-message)

```
$gupshup = new OutboundMessage('SRC_NAME', 'SOURCE', 'API_KEY');
```

#### Send Text

[](#send-text)

```
$gupshup->setText('Texto de prueba');
$gupshup->sendRequest('573111111111');
```

#### Send Image

[](#send-image)

```
$url = "https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample01.jpg";
$caption =  "Sample image";

$gupshup->setImage($url, $caption);
$gupshup->sendRequest('573111111111');
```

#### Send Audio

[](#send-audio)

```
$url = "https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample01.jpg";

$gupshup->setAudio($url);
$gupshup->sendRequest('573111111111');
```

#### Send File

[](#send-file)

```
$url = "https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf";
$filename = "Sample funtional resume";

$gupshup->setFile($url, $filename);
$gupshup->sendRequest('573111111111');
```

#### Send Video

[](#send-video)

```
$url = "https://www.buildquickbots.com/whatsapp/media/sample/video/sample01.mp4";
$caption = "Sample video";

$gupshup->setFile($url, $filename);
$gupshup->sendRequest('573111111111');
```

#### Send Sticker

[](#send-sticker)

```
$url = "http://www.buildquickbots.com/whatsapp/stickers/SampleSticker01.webp";

$gupshup->setFile($url, $filename);
$gupshup->sendRequest('573111111111');
```

#### Send List Messages

[](#send-list-messages)

```
$globalButtons[] = [
    'type' => 'text',
    'title' => 'Escoger'
];

$items[] = [
    'title' => 'first Section',
    'subtitle' => 'first Subtitle',
    'options' => [
        [
            'type' => 'text',
            'title' => 'section 1 row 1',
            'description' => 'first row of 1 section description',
            'postbackText' => 'section 1 row 1 postback payload'
        ],
        [
            'type' => 'text',
            'title' => 'section 1 row 2',
            'description' => 'second row of 2 section description',
            'postbackText' => 'section 1 row 2 postback payload'
        ],
        [
            'type' => 'text',
            'title' => 'section 1 row 3',
            'description' => 'second row of 3 section description',
            'postbackText' => 'section 1 row 3 postback payload'
        ]
    ]
];

$items[] = [
    'title' => 'Segunda Sección',
    'subtitle' => 'Segundo Subtitulo',
    'options' => [
        [
            'type' => 'text',
            'title' => 'section 2 row 1',
            'description' => 'first row of 1 section description',
            'postbackText' => 'section 1 row 1 postback payload'
        ],
        [
            'type' => 'text',
            'title' => 'section 2 row 2',
            'description' => 'second row of 2 section description',
            'postbackText' => 'section 1 row 2 postback payload'
        ],
        [
            'type' => 'text',
            'title' => 'section 2 row 3',
            'description' => 'second row of 3 section description',
            'postbackText' => 'section 1 row 3 postback payload'
        ]
    ]
];

// Params: $title, $body, $msgid, $globalButtons, $items
$gupshup->setListMessage('title text', 'body text', rand(), $globalButtons, $items);
$gupshup->sendRequest("57311111111");
```

#### Send Quick replies

[](#send-quick-replies)

```
$content = [
    'type' => 'text',
    'header' => 'this is the header',
    'text' => 'this is the body',
    'caption' => 'this is the footer'
];

$options = [
    [
        'type'          => 'text',
        'title'         => 'Firts',
    ],
    [
        'type'          => 'text',
        'title'         => 'Second',
    ],
    [
        'type'          => 'text',
        'title'         => 'Third',
    ]
];

$msgid = rand();
$gupshup->setQuickRepliesText($msgid, $content, $options);
$gupshup->sendRequest("57311111111");
```

#### Send Quick Replies Text

[](#send-quick-replies-text)

```
$content = [
    'type' => 'text',
    'header' => 'this is the header',
    'text' => 'this is the body',
    'caption' => 'this is the footer'
];

$options = [
    [
        'type'          => 'text',
        'title'         => 'Firts',
    ],
    [
        'type'          => 'text',
        'title'         => 'Second',
    ],
    [
        'type'          => 'text',
        'title'         => 'Third',
    ]
];

$msgid = rand();
$gupshup->setQuickRepliesText($msgid, $content, $options);
$gupshup->sendRequest("57311111111");
```

#### Get Template list

[](#get-template-list)

```
$templates = $gupshup->getTemplates();
```

#### Send a message through a template

[](#send-a-message-through-a-template)

```
$idtemplate = 'aaaaa-bbbbb-ccccc-dddd-eeee';
$templateparams =  [
    "Agent",
    "Local Address",
    "Tracking code"
];

$gupshup->setTemplate($idtemplate, $templateparams);
$gupshup->sendTemplate("57311111111");
```

#### Get Opt-in User list

[](#get-opt-in-user-list)

```
$response = $gupshup->getOptin();
```

#### Mark User Opt-in Opt-out

[](#mark-user-opt-in-opt-out)

```
$response = $gupshup->markOpt('573111111111', 'in');
$response = $gupshup->markOpt('573111111111', 'out');
```

#### Check Wallet balance

[](#check-wallet-balance)

```
$response = $gupshup->getWalletBalance();
```

### Inbound Message and Events

[](#inbound-message-and-events)

```
