DEMO: InternationalSMS/Template - 國際短信模板管理
代碼示例
<?php
/*****************
* 非加密請求 示例代碼
******************/
//---------------------------------get 獲取國際短信模板數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//模板ID 國際短信-創(chuàng)建/管理國際短信模板中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$template_id = "F***U"; //國際短信模板ID
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'template_id' => $template_id
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => "https://api-v4.mysubmail.com/internationalsms/template.json?".http_build_query($post_data),
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_POST => 0,
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);
//---------------------------------post 創(chuàng)建國際短信模板-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//生成模板如下
// 您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$title = '國際短信模板標(biāo)題'; //國際短信模板標(biāo)題
$content = '您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。'; //國際短信正文
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'sms_title' => $title,
'sms_content' => $content
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/internationalsms/template.json',
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $post_data
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);
//---------------------------------put 更新國際短信模板-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//模板ID 國際短信-創(chuàng)建/管理國際短信模板中獲得
//生成模板如下
// 【國際短信模板簽名】您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$title = '國際短信模板標(biāo)題'; //國際短信模板標(biāo)題
$signature = '國際短信模板簽名'; //國際短信模板簽名
$content = '您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。'; //國際短信正文
$template_id = 'F***U'; //國際短信模板ID
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'sms_title' => $title,
'template_id' => $template_id,
'sms_content' => $content
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/internationalsms/template.json',
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => http_build_query($post_data) ,
CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded")
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);
//---------------------------------delete 刪除模板-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//模板ID 國際短信-創(chuàng)建/管理國際短信模板中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$template_id = 'F***U'; //國際短信模板ID
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'template_id' => $template_id,
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/internationalsms/template.json' ,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_POSTFIELDS => http_build_query($post_data),
CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded")
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);
/*****************
* 加密請求 示例代碼
******************/
//---------------------------------get 獲取國際短信模板數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//模板ID 國際短信-創(chuàng)建/管理國際短信模板中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$template_id = "F***U"; //國際短信模板ID
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/service/timestamp.json',
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_POST => 0
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
$timestamp = $output['timestamp'];
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'template_id' => $template_id,
'sign_type' => 'md5',
'timestamp' => $timestamp
);
$temp = $post_data;
ksort($temp);
reset($temp);
unset($temp['signature']);
$str = "";
foreach ($temp as $key => $value) {
$str.=$key."=".$value."&";
}
$str = substr($str,0,-1);
$post_data['signature'] = md5($appid.$appkey.$str.$appid.$appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => "https://api-v4.mysubmail.com/internationalsms/template.json?".http_build_query($post_data),
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_POST => 0,
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);
//---------------------------------post 創(chuàng)建國際短信模板-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//生成模板如下
// 【國際短信模板簽名】您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$title = '國際短信模板標(biāo)題'; //國際短信模板標(biāo)題
$signature = '國際短信模板簽名'; //國際短信模板簽名
$content = '您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。'; //國際短信正文
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/service/timestamp.json',
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_POST => 0 ,
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
$timestamp = $output['timestamp'];
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'sms_title' => $title,
'sms_content' => $content ,
'sign_type' => 'md5',
'timestamp' => $timestamp,
);
$temp = $post_data;
ksort($temp);
reset($temp);
unset($temp['signature']);
$str = "";
foreach ($temp as $key => $value) {
$str.=$key."=".$value."&";
}
$str = substr($str,0,-1);
//生成簽名
$post_data['signature'] = md5($appid.$appkey.$str.$appid.$appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/internationalsms/template.json',
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1 ,
CURLOPT_POSTFIELDS => $post_data
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);
//---------------------------------put 更新國際短信模板-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//模板ID 國際短信-創(chuàng)建/管理國際短信模板中獲得
//生成模板如下
// 【國際短信模板簽名】您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$title = '國際短信模板標(biāo)題'; //國際短信模板標(biāo)題
$content = '您的驗證碼是@var(code),請在@var(time)內(nèi)輸入。'; //國際短信正文
$template_id = 'F***U'; //國際短信模板ID
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/service/timestamp.json' ,
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_POST => 0 ,
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
$timestamp = $output['timestamp'];
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'sms_title' => $title,
'template_id' => $template_id,
'sms_content' => $content,
'sign_type' => 'md5',
'timestamp' => $timestamp
);
$temp = $post_data;
ksort($temp);
reset($temp);
unset($temp['signature']);
$str = "";
foreach ($temp as $key => $value) {
$str.=$key."=".$value."&";
}
$str = substr($str,0,-1);
//生成簽名
$post_data['signature'] = md5($appid.$appkey.$str.$appid.$appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/internationalsms/template.json',
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => http_build_query($post_data),
CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded")
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);
//---------------------------------delete 刪除模板-------------------------------------
//appid參數(shù) appkey參數(shù)在 國際短信-創(chuàng)建/管理AppID中獲取
//模板ID 國際短信-創(chuàng)建/管理國際短信模板中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$template_id = 'F***U'; //國際短信模板ID
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/service/timestamp.json' ,
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_POST => 0 ,
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
$timestamp = $output['timestamp'];
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'template_id' => $template_id,
'sign_type' => 'md5',
'timestamp' => $timestamp
);
$temp = $post_data;
ksort($temp);
reset($temp);
unset($temp['signature']);
$str = "";
foreach ($temp as $key => $value) {
$str.=$key."=".$value."&";
}
$str = substr($str,0,-1);
//生成簽名
$post_data['signature'] = md5($appid.$appkey.$str.$appid.$appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://api-v4.mysubmail.com/internationalsms/template.json' ,
CURLOPT_RETURNTRANSFER => 1 ,
CURLOPT_CUSTOMREQUEST => 'DELETE' ,
CURLOPT_POSTFIELDS => http_build_query($post_data) ,
CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded")
));
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output,true);
print_r($output);