-
Notifications
You must be signed in to change notification settings - Fork 19
/
Action.php
44 lines (40 loc) · 1.22 KB
/
Action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class AliceStyle_Action extends Widget_Abstract_Contents implements Widget_Interface_Do
{
public function action()
{
$options = Helper::options();
$appkey = $options->plugin('AliceStyle')->appkey;
$talkContent = "";
$info=addslashes($_POST['info']);
$userid=addslashes($_POST['userid']);
function send_post($url, $post_data) {
$postdata = http_build_query($post_data);
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => $postdata,
'timeout' => 15 * 60 // 超时时间(单位:s)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result;
}
//使用方法
$post_data = array(
'key' => $appkey,
'info' => $info,
'userid' => $userid,
);
if($appkey==""){
$talkContent = '{"code":"500","text":"我还没学会聊天功能,快和站长联系吧!"}';
}
else{
$talkContent = send_post('http://www.tuling123.com/openapi/api', $post_data);
}
header('Content-type:text/json');
echo $talkContent;
}
}