sendPush
发送站内信接口
请求地址 :
| 环境 | 提交方式 | HTTPS请求地址 |
|---|---|---|
| 正式环境 | POST | https://open.hexinpass.com:8501/api/sendPush |
公共参数 :
| 参数 | 类型 | 是否必填 | 描述 | 示例值 |
|---|---|---|---|---|
| telephone | string | 是 | 手机号 | 18180****25 |
| channel | string | 是 | 通道 | 010 |
| pushTime | int | 是 | 推送时间(UTC时间) 0:立即推送 | 0 |
| typeId | int | 是 | 消息分类 0系统消息 | 0 |
| description | string | 是 | 消息描述 | |
| title | string | 是 | 消息标题 | |
| img | string | 否 | 图片路径 | |
| contentType | int | 是 | 消息类型 | |
| content | int | 是 | 消息内容 |
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
|
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 sendPush()
{
$result = $this->getToken(); //获取token值
if( $result['errcode'] !== 0 && $result['msg']
!= 'success' )
{
die($result);
}
$token = $result['token'];
$params = array(
'telephone' =>
"18190756214",
'channel' =>
"010",
'pushTime' =>
0,
'typeId' =>
0,
'description' =>
"消息描述",
'title' =>
"消息标题",
'img' =>
"",
'contentType' =>
1,
'url' =>
"",
'content' =>
"消息内容",
);
$url =
$this->tKweb.'/api/merchantIdsList?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->sendPush();
//输出信息
print_r($result);
//返回成功信息
Array
(
[data] =>
[errcode] => 0
[msg] => success
)
|