DEMO: ShortURL/Group - 短網(wǎng)址群組
代碼示例
短網(wǎng)址群組
<?php
/*****************
*
* 非加密請求 示例代碼
*
******************/
//---------------------------------get 獲取短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組ID 短網(wǎng)址-創(chuàng)建/管理短網(wǎng)址群組中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$group = 'f3***************************f1'; //短網(wǎng)址群組ID
$post_data = array(
'appid' => $appid,
'signature' => $appkey,
'group' => $group,
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => "https://service.mysubmail.com/shorturl/group?".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 生成短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組昵稱
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$name = '短網(wǎng)址群組昵稱'; //短網(wǎng)址群組昵稱
$post_data = array(
'appid' => $appid ,
'signature' => $appkey ,
'name' => $name
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://service.mysubmail.com/shorturl/group' ,
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 更新短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組ID 短網(wǎng)址-創(chuàng)建/管理短網(wǎng)址群組中獲得
//短網(wǎng)址群組昵稱
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$group = 'f3***************************f1'; //短網(wǎng)址群組ID
$name = '短網(wǎng)址群組昵稱'; //短網(wǎng)址群組昵稱
$post_data = array(
'appid' => $appid ,
'signature' => $appkey ,
'group' => $group ,
'name' => $name
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://service.mysubmail.com/shorturl/group' ,
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 刪除短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組ID 短網(wǎng)址-創(chuàng)建/管理短網(wǎng)址群組中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$group = 'f3***************************f1'; //短網(wǎng)址群組ID
$post_data = array(
'appid' => $appid ,
'signature' => $appkey ,
'group' => $group ,
);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://service.mysubmail.com/shorturl/group' ,
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 獲取短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組ID 短網(wǎng)址-創(chuàng)建/管理短網(wǎng)址群組中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$group = 'f3***************************f1'; //短網(wǎng)址群組ID
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://api.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 ,
"group" => $group ,
"timestamp" => $timestamp,
"sign_type" => 'md5',
);
//整理生成簽名所需參數(shù)
$temp = $post_data;
unset($temp['group']);
ksort($temp);
reset($temp);
$tempStr = "";
foreach ($temp as $key => $value) {
$tempStr .= $key . "=" . $value . "&";
}
$tempStr = substr($tempStr, 0, count($tempStr) - 2);
//生成簽名
$post_data['signature'] = md5($appid . $appkey . $tempStr . $appid . $appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => "https://service.mysubmail.com/shorturl/group?".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 生成短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組昵稱
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$name = '短網(wǎng)址群組昵稱'; //短網(wǎng)址群組昵稱
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://api.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 ,
"name" => $name ,
"timestamp" => $timestamp,
"sign_type" => 'md5',
);
//整理生成簽名所需參數(shù)
$temp = $post_data;
unset($temp['name']);
ksort($temp);
reset($temp);
$tempStr = "";
foreach ($temp as $key => $value) {
$tempStr .= $key . "=" . $value . "&";
}
$tempStr = substr($tempStr, 0, count($tempStr) - 2);
//生成簽名
$post_data['signature'] = md5($appid . $appkey . $tempStr . $appid . $appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://service.mysubmail.com/shorturl/group' ,
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 更新短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組ID 短網(wǎng)址-創(chuàng)建/管理短網(wǎng)址群組中獲得
//短網(wǎng)址群組昵稱
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$group = 'f3***************************f1'; //短網(wǎng)址群組ID
$name = '短網(wǎng)址群組昵稱'; //短網(wǎng)址群組昵稱
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://api.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 ,
"name" => $name ,
"group" => $group ,
"timestamp" => $timestamp,
"sign_type" => 'md5',
);
//整理生成簽名所需參數(shù)
$temp = $post_data;
unset($temp['name']);
unset($temp['group']);
ksort($temp);
reset($temp);
$tempStr = "";
foreach ($temp as $key => $value) {
$tempStr .= $key . "=" . $value . "&";
}
$tempStr = substr($tempStr, 0, -1);
//生成簽名
$post_data['signature'] = md5($appid . $appkey . $tempStr . $appid . $appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://service.mysubmail.com/shorturl/group' ,
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 刪除短網(wǎng)址群組數(shù)據(jù)-------------------------------------
//appid參數(shù) appkey參數(shù)在 短網(wǎng)址-創(chuàng)建/管理AppID中獲取
//短網(wǎng)址群組ID 短網(wǎng)址-創(chuàng)建/管理短網(wǎng)址群組中獲得
$appid = '6***3'; //appid參數(shù)
$appkey = '5d****************************58'; //appkey參數(shù)
$group = 'f3***************************f1'; //短網(wǎng)址群組ID
//通過接口獲取時間戳
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://api.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 ,
"group" => $group ,
"timestamp" => $timestamp,
"sign_type" => 'md5',
);
//整理生成簽名所需參數(shù)
$temp = $post_data;
unset($temp['group']);
ksort($temp);
reset($temp);
$tempStr = "";
foreach ($temp as $key => $value) {
$tempStr .= $key . "=" . $value . "&";
}
$tempStr = substr($tempStr, 0, -1);
//生成簽名
$post_data['signature'] = md5($appid . $appkey . $tempStr . $appid . $appkey);
$ch = curl_init();
curl_setopt_array($ch , array(
CURLOPT_URL => 'https://service.mysubmail.com/shorturl/group' ,
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);