Download the PHP package avplab/viber-api without Composer

On this page you can find all versions of the php package avplab/viber-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package viber-api

ViberApi

The ViberApi gives an ability to create fully functional php bots for Viber, based on Viber REST API.

Installation

Install the component by using Composer. Update your project's composer.json file to include dependency.

"require": {
    "avplab/viber-api": "^1.0.0"
}

Usage

To create any bot, the package provides two base classes Callback\Request and Client.

Registration

Run the following script once to register your webhook(bot). It could be run locally.

Code

Once you are done with registration you can write the code of the bot

Get request from API

The Request provides all the information about callback-request from the Viber API to your server. You can trust the request data, as it is verified for authenticity (see X-Viber-Content-Signature). If for some reason the request cannot be processed, a BadRequestException will be thrown.

Send request to API

To send requests to the API, the Client object is used(the request is sent based on cURL). If for some reason the request does not reach the API, a ServerErrorResponseException exception will be thrown. If the API received the request, but for some reason responded with an error (see API errors), an ApiException exception will be thrown.

Messages

The API is using term "message" as request body. Message is a JSON which has predefined structure(see the API docs). Viber describes several types of messages: text, picture, video, contact, rich-media, file, sticker, location and url. To prepare the specific message for sending to the API, you have to create an object of one of the predefined classes:

Keyboards

Each message may contain a keyboard. To add the keyboard use the Keyboard objects(see Keyboard methods for details).

API

AvpLab/Callback/Request

The request object which contains all the info sent by Viber API

AvpLab/Client

The http client which communicates with Viber API.

Framework

To simplify the bot's creation and make the code cleaner there is also a framework provided.

Usage

Routing

The framework supports the routing system. It allows to configure the specific paths for an appropriate controller action.

There are also parameters available. It should be started with colon:

Framework API

All functionality is located under the AvpLab/ViberApi/Framework namespace

Bot Class

The Bot class is the main class which should be used to configure the bot. To configure the paths and appropriate handlers the onMessage() method should be used.

There are also several methods available:

Once the bot is configured the run() must be called.

Controller Class

The Controller is the base class which is used to create handlers. You are free to provide own function as the handler but then you have to create the ControllerRequest object manually. To become an action the controller's method must be ended with "Action" suffix. There are several methods avaiable:

ControllerRequest Class

Represents the Request object with few extra methods regarding the controller's context

Links

1) Viber REST API

License

ViberApi is licensed under the MIT License - see the LICENSE file for details


All versions of viber-api with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package avplab/viber-api contains the following files

Loading the files please wait ....