-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathami_papa.php
executable file
·75 lines (61 loc) · 2.1 KB
/
ami_papa.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
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
<?php
include_once ('db.class.php');
include_once ('config.php');
include_once ('saetv2.ex.class.php');
include_once ('util.php');
$db = new DBManager();
$tkn = $db -> getToken();
// since id to avoid duplication
$since_id = $db -> getCSinceId();
$c = new SaeTClientV2(WB_AKEY, WB_SKEY, $tkn);
$ms = $c -> comments_to_me(1, 200, $since_id, 0, 0, 0);
//$statuses = $ms['statuses'];
$comments = $ms['comments'];
// store mentions to database
foreach (array_reverse($comments) as $item) {
// weibo id
$weibo_id = $item['id'];
// mid of this comment, add by jerremy
$mid = $item['status']['mid'];
// user screen name
$name = $item['user']['screen_name'];
// weibo text
$text = $item['text'];
// replace motion as [兔子], add by jerremy
$text = preg_replace("/\[([^]]+)]/i", "", $text);
$text = preg_replace('/回复.*:/', '', $text);
if(0 == strlen($text)){
echo '<br/> emotions only: '.$text;
continue;
}
// check if no word, add by jerremy
if(0 == isNoWord($text)){
echo '<br/> no word: '.$text;
continue;
}
// if (substr_count($text, "@浙大CCNT实验室饮水机") > 0)
// {
$text = str_replace("@浙大CCNT实验室饮水机"," ", $text);
echo 'Storing: id=' . $weibo_id . ' mid=' . $mid . ' name=' . $name . ' text=' . $text . '<br/>';
$ami = new Ami();
$ami -> weiboid = $weibo_id;
$ami -> mid = $mid;
$ami -> name = $name;
$ami -> text = $text;
// $db -> ami_add_question($weibo_id, $name, $text);
$db -> addAmiPl($ami);
// }
$since_id = $weibo_id;
$db -> setCSinceId($since_id);
}
function isNoWord($str){
$tmp = preg_replace("/[[:punct:]]/", "",$str);
$tmp = preg_replace("/([\x{3002}\x{ff1b}\x{ff0c}\x{ff1a}\x{201c}\x{201d}\x{ff08}\x{ff09}\x{3001}\x{ff1f}\x{300a}\x{300b}])/u", "",$tmp);
$tmp = preg_replace('/([a-zA-Z]|\d)+/', '', $tmp);
if(0 == strlen($tmp)){
return 0;
}
return 1;
}
// update since_id
?>