PHP code example of crunchzapp / crunchzapp-php-sdk
1. Go to this page and download the library: Download crunchzapp/crunchzapp-php-sdk 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/ */
crunchzapp / crunchzapp-php-sdk example snippets
use CrunchzApp\CrunchzApp;
$token = 'your-api-token';
$crunchz = new CrunchzApp($token);
// You can now use the $crunchz object to interact with the API
$response = $crunchz->channel()->health();
use CrunchzApp\CrunchzApp;
// Initialize the service
$crunchz = app(CrunchzApp::class);
// Send a text message
$response = $crunchz->channel()
->contact('[email protected]')
->text('Hello, World!')
->send();
// Send an image with caption
$response = $crunchz->channel()
->contact('[email protected]')
->image('https://example.com/image.jpg', 'Check this out!')
->send();
// Send a location
$response = $crunchz->channel()
->contact('[email protected]')
->location(-6.2088, 106.8456, 'Jakarta, Indonesia')
->send();
// Send a video with caption
$response = $crunchz->channel()
->contact('[email protected]')
->video('https://example.com/video.mp4', 'Amazing video!')
->send();
// Generate and send OTP link
$otpService = $crunchz->otp('link');
$response = $otpService
->contact('[email protected]')
->send();
// Get all contacts
$contacts = $crunchz->channel()
->allContact()
->send();
// Get contact details
$contactDetails = $crunchz->channel()
->detail('[email protected]')
->send();
// Get contact picture
$contactPicture = $crunchz->channel()
->picture('[email protected]')
->send();
// Get all chats
$chats = $crunchz->channel()
->allChat()
->send();
// Get chat details
$chatDetails = $crunchz->channel()
->chatDetail('[email protected]')
->send();
// Archive a chat
$crunchz->channel()
->archiveChat('[email protected]')
->send();
// Unarchive a chat
$crunchz->channel()
->unArchiveChat('[email protected]')
->send();
// Get all groups
$groups = $crunchz->channel()
->allGroup()
->send();
// Create a new group
$newGroup = $crunchz->channel()
->createGroup('My Group', [
'[email protected]',
'[email protected]'
])
->send();
// Get group participants
$participants = $crunchz->channel()
->participants('group_id_here')
->send();