couponslist
电子劵列表
请求地址 :
| 环境 | 提交方式 | HTTPS请求地址 |
|---|---|---|
| 正式环境 | POST | https://open.hexinpass.com:8501/api/couponslist |
公共参数 :
| 参数 | 类型 | 是否必填 | 描述 | 示例值 |
|---|---|---|---|---|
| page | number | 是 | page | 1 |
| pageSize | number | 是 | 页面大小 | 20 |
PHP示例代码 :
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
class Demo {
public $pid = 'hxiaoming'; //第三方用户唯一凭证
public $secret = '850a554f3072867d52d56169201a9737';
//第三方用户唯一凭证密钥
public $tKweb = 'https://open.hexinpass.com:8501/';
//第三方接口地址
/** * 获取Token */
public function getToken()
{
$url =
$this->tKweb."/access/gettoken?pid=".$this->pid.'&secret='.$this->secret;
$res =
$this->requestPost($url);
return json_decode($res ,
true);
}
/** * 获取电子劵列表 */
public function couponslist()
{
$result = $this->getToken(); //获取token值
if( $result['errcode'] !== 0 && $result['msg']
!= 'success' )
{
die($result);
}
$token = $result['token'];
$params = array(
'page' => 1,
'pageSize' => 10
);
$url =
$this->tKweb.'/api/couponslist?token='.$token;
$res = $this->requestPost($url
,json_encode($params));
$result = json_decode($res , true);
$return $result;
}
/** * * 请求方式 * curl post */
public function requestPost($url , $params =
'')
{
$cn = curl_init();
curl_setopt($cn, CURLOPT_URL, $url);
curl_setopt($cn, CURLOPT_RETURNTRANSFER,
1);
curl_setopt($cn, CURLOPT_POST, true);
curl_setopt($cn, CURLOPT_POSTFIELDS,
$params);
curl_setopt($cn, CURLOPT_TIMEOUT, 30 );
$res = curl_exec($cn);
$httpCode =
curl_getinfo($cn,CURLINFO_HTTP_CODE);
curl_close($cn);
return $res;
}
}
//创建对象
$demo = new Demo();
//执行对象方法
$result = $demo->couponslist();
//输出信息
print_r($result);
//返回成功信息
Array
(
[data] => Array
(
[List] => Array
(
[0] => Array
(
[templateID]
=> 268
[name]
=> 开放平台测试券
[img]
=> coupons_default_image
[effectiveType]
=> 1
[relativeTime]
=> 4752000
[maxCount]
=> 99
[remark]
=> coupons_default_remark
[notes]
=> 撒旦阿斯顿阿斯顿啊司法舒服啊司法电风扇佛挡杀佛水电费但是分手
[absoluteStart]
=> 0
[absoluteEnd]
=> 0
[applyCount]
=> 4
[createTime]
=> 1478596105
)
)
[count] =>
1
)
[errcode] => 0
[msg] =>
)
|