1. Go to this page and download the library: Download xaamin/whatsapi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Include the composer autoload file
Xaamin\Whatsapi\Facades\Native\Whatsapi;
use Xaamin\Whatsapi\Facades\Native\Registration;
// Or, if you want you can add a class alias
// class_alias('Xaamin\Whatsapi\Facades\Native\Whatsapi', 'Whatsapi');
// class_alias('Xaamin\Whatsapi\Facades\Native\Registration', 'Registration');
// Of course, you can use the Config class from your favorite Framework.
$config = __DIR__ . 'config/whatsapi.php';
Whatsapi::setConfig($config);
# Codeigniter 3 example
use CI_Session;
use Xaamin\Whatsapi\Sessions\SessionInterface;
class SessionManager implements SessionInterface{
# The key used in the Session.
protected $key = 'itnovado_whatsapi';
# Session object.
protected $session;
public function __construct(CI_Session $session)
{
$this->session = $session;
}
public function getKey()
{
return $this->key;
}
public function put($value)
{
$this->session->set_userdata($this->getKey(), $value);
}
public function pull()
{
$data = $this->session->userdata($this->getKey());
$this->session->unset_userdata($this->getKey());
return $data;
}
}
// Get some resources
$ci =& get_instance();
$ci->load->driver('session');
$sessionManager = new SessionManager($ci->session);
// Override the default session implementation
Whatsapi::setSessionManager($sessionManager);
$number = '5219511552222'; # Number with country code
$code = '132456'; # Replace with received code
$response = WhatsapiTool::registerCode($number, $code);