Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mahircoding/1adc1f1bcb53beb62adf08945d8195d9 to your computer and use it in GitHub Desktop.
Save mahircoding/1adc1f1bcb53beb62adf08945d8195d9 to your computer and use it in GitHub Desktop.
kirim email php
function get_kirim_email_list()
{
require '../vendor/autoload.php';
require '../config/database.php';
$user_id = $_SESSION['user_id'];
$user = \SI\Model\User::whereId($user_id)->first();
$api_token = $user->api_kirimemail;
$username = $user->user_kirimemail;
$base_url = 'https://api.kirim.email/v3/list?nolimit=true';
$timestamp = time();
$api_username = $username;
$api_token = $api_token;
$auth_str = rtrim(ltrim($api_username)) . "::" . rtrim(ltrim($api_token)) . "::" . $timestamp;
$token = hash_hmac("sha256", $auth_str, rtrim(ltrim($api_token)));
// Initialize cURL
$curl = curl_init();
$headers = array(
'Auth-Id: ' . $api_username,
'Auth-Token: ' . $token,
'Timestamp: ' . $timestamp,
'User-Agent: KirimEmail/WooCommerce'
);
curl_setopt_array($curl, array(
CURLOPT_URL => $base_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 60,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => $headers
));
$body = curl_exec($curl);
curl_close ($curl);
$json = json_decode($body, true);
if( $json['code'] == 200 ) {
foreach( $json['data'] as $list ) {
$listmail[ $list['id'] ] = $list['name'];
}
}
return $listmail;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment