PHP code example of infobip-ecommerce / api-php-client
1. Go to this page and download the library: Download infobip-ecommerce/api-php-client 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/ */
infobip-ecommerce / api-php-client example snippets
$configuration = (new Configuration())
->setHost(URL_BASE_PATH)
->setApiKeyPrefix('Authorization', API_KEY_PREFIX)
->setApiKey('Authorization', API_KEY);
$client = new GuzzleHttp\Client();
$sendSmsApi = new SendSMSApi($client, $configuration);
$destination = (new SmsDestination())->setTo('41793026727');
$message = (new SmsTextualMessage())
->setFrom('InfoSMS')
->setText('This is a dummy SMS message sent using infobip-api-php-client')
->setDestinations([$destination]);
$request = (new SmsAdvancedTextualRequest())
->setMessages([$message]);
$previewResponse = $sendSmsApi->previewSmsMessage((new SmsPreviewRequest())
->setText("Let's see how many characters will remain unused in this message."));
echo $previewResponse;
piInstance = new Infobip\Api\SendWhatsappApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$pi_integrator = 56; // int
$pi_platform = 'pi_platform_example'; // string
$whatsapp_message = new \Infobip\Model\WhatsappMessage(); // \Infobip\Model\WhatsappMessage
try {
$result = $apiInstance->sendWhatsappMessage($pi_integrator, $pi_platform, $whatsapp_message);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling SendWhatsappApi->sendWhatsappMessage: ', $e->getMessage(), PHP_EOL;
}
piInstance = new Infobip\Api\WhatsappTemplatesApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client()
);
$sender = 56; // int | Sender number wit country code
try {
$result = $apiInstance->getTemplates($sender);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling WhatsappTemplatesApi->getTemplates: ', $e->getMessage(), PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.