1. Go to this page and download the library: Download direct7/direct7-php 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/ */
direct7 / direct7-php example snippets
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token")
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->sms->sendMessage(
'Sender',
'https://example.com/callback',
'2024-02-05T10:17:10+0000',
[
'recipients' => ["+91999XXXXXXX"],
'content' => 'Greetings from D7 API',
'unicode' => false,
],
);
var_dump($response);
use direct7\Direct7\Client;
$client = new Client(api_token="Your API token")
$response = $direct7->sms->sendMessage(
'Sender',
'https://example.com/callback',
null,
[
'recipients' => ["+919999XXXXXX"],
'content' => 'لوحة المفاتيح العربية!',
'unicode' => true,
]
);
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
# request_id is the id returned in the response of send_message
$response = $direct7->sms->getStatus(request_id:'00145469-b503-440a-bb0c-59af8a598a7f');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->verify->sendOtp(originator:'SignOTP', recipient:'+91999999XXXX', content:'Greetings from D7 API, your mobile verification code is: {}', data_coding:'text', expiry:600);
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->verify->resendOtp(otpId:'9c476ed0-c1ce-43e2-8576-ec505902e987');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->verify->verifyOtp(otpId:'31b89954-d37c-426f-8113-ac718afc5d4c', otpCode:'429766');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->verify->getStatus(otpId:'31b89954-d37c-426f-8113-ac718afc5d4c');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->whatsapp->sendWhatsAppFreeformMessage(
originator:"9715XXXXXXX",
recipient:"91XX8675XXXX",
message_type:"LOCATION",
latitude: "12.93803129081362",
longitude: "77.61088653615994",
name: "Pvt Ltd",
address: "Bengaluru, Karnataka"
);
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$body_parameter_values = ["0" => 'first_parameter_in_your_template'];
$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
originator: '9715XXXXXXX',
recipient: '91XX8675XXXX',
language: 'en',
template_id: 'template_id',
body_parameter_values: $body_parameter_values,
);
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$parameters = [
"display_text" => "Visit Us",
"url" => "https://www.luckyshrub.com?clickID=kqDGWd24Q5TRwoEQTICY7W1JKoXvaZOXWAS7h1P76s0R7Paec4"
];
$response = $direct7->whatsapp->sendWhatsAppInteractiveMessage(
originator:"9715XXXXXXX",
recipient:"91XX8675XXXX",
interactive_type:"cta_url",
header_type:"text",
header_text:"Payment$ for D7 Whatsapp Service",
body_text:"Direct7 Networks is a messaging service provider that specializes in helping organizations efficiently communicate with their customers.",
footer_text:"Thank You",
parameters: $parameters
);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->whatsapp->getStatus('469affd7-0983-4bbc-9d07-ee43e1d1cfef');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->number_lookup->searchNumberDetails(recipient:'+91999999XXXX');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->viber->sendViberMessage(recipients:['+91999999XXXX'], content:'Hello, World!', label:'PROMOTION', originator:'SignOTP', call_back_url:'https://example.com/callback');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->viber->getStatus(request_id:'deb7c268-cde9-4782-a4a7-9bc03a82bd1d');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->slack->sendSlackMessage(content:'Hello, World!', work_space_name:'WorkSpaceName', channel_name:'ChannelName', report_url:'https://example.com/callback');
var_dump($response);
use direct7\Direct7\Client;
$direct7 = new Client(api_token="Your API token");
$response = $direct7->viber->getStatus(request_id:'deb7c268-cde9-4782-a4a7-9bc03a82bd1d');
var_dump($response);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.