OneSender sudah terintegrasi dengan wafu. Silahkan pilih layanan OneSender v2 di salah satu opsi service wa.
Debug Error
Gagal kirim gambar
Jika gagar kirim gambar. Silahkan ubah dahulu kode service onesender.
Ubah dengan kode berikut
<?php
/*
Service Name: OneSender v2
Service URL: https://onesender.id
API Documentation: https://onesender.id/docs/
Field API Server: onesenderv2_server
Field API Key: onesenderv2_key
*/
if (!defined('WAFU_SCRIPT')) { die(); exit; }
if (isset($wafusetting['onesenderv2_server']) && $wafusetting['onesenderv2_server'] != '') {
$api_url = trim($wafusetting['onesenderv2_server']);
if ('/' == substr($api_url, -1)) {
$api_url .= 'api/v1/messages';
} else if ('/api' == substr($api_url, -4)) {
$api_url .= '/v1/messages';
}
$api_url = str_replace('/api/api/', '/api/', $api_url);
$api_key = trim($wafusetting['onesenderv2_key']);
$message = array(
'recipient_type' => 'individual',
'to' => $nohp,
'type' => 'text',
'text' => array('body' => stripslashes($pesan)),
);
if ($gambar != '') {
$upload_obj = wp_get_upload_dir();
$gambar = $upload_obj['baseurl'] . '/pic/' . $gambar;
if ($gambar) {
$image_msg = array(
'link' => $gambar
);
if (!empty($pesan)) {
$image_msg['caption'] = stripslashes($pesan);
}
$message = array(
'recipient_type' => 'individual',
'to' => $nohp,
'type' => 'image',
'image' => $image_msg,
);
}
}
$conn_args = array(
'method' => 'POST',
'timeout' => 45,
'sslverify' => false,
'headers' => array(
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json'
),
'body' => json_encode($message),
);
$request = wp_remote_post($api_url, $conn_args);
$return = "Berhasil";
if (is_wp_error($request) || wp_remote_retrieve_response_code($request) != 200) {
$return = "Gagal kirim pesan";
}
}