line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Yahoo::Lifestyle; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26271
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
1335
|
use Yahoo::BBAuth; |
|
1
|
|
|
|
|
111894
|
|
|
1
|
|
|
|
|
13
|
|
5
|
1
|
|
|
1
|
|
37
|
use LWP; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
545
|
use XML::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.2'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
|
|
|
|
|
|
my $self = shift; |
12
|
|
|
|
|
|
|
my $param = shift; |
13
|
|
|
|
|
|
|
my $appid = $param->{appid}; |
14
|
|
|
|
|
|
|
my $version = 'v0.1'; |
15
|
|
|
|
|
|
|
my $url = 'http://tw.lifestyle.yahooapis.com/'; |
16
|
|
|
|
|
|
|
my $request = $url.$version."/"; |
17
|
|
|
|
|
|
|
bless ( { |
18
|
|
|
|
|
|
|
version => $version, |
19
|
|
|
|
|
|
|
url => $url, |
20
|
|
|
|
|
|
|
appid => $appid, |
21
|
|
|
|
|
|
|
request => $request }, |
22
|
|
|
|
|
|
|
$self); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub auth { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
my $param = shift; |
28
|
|
|
|
|
|
|
my $secret = $param->{secret}; |
29
|
|
|
|
|
|
|
my $bbauth = Yahoo::BBAuth->new( |
30
|
|
|
|
|
|
|
appid => $self->{appid}, |
31
|
|
|
|
|
|
|
secret => $secret, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
bless ( { auth => $bbauth }, $self); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub Bizsearch { |
37
|
|
|
|
|
|
|
# we don't need the bbauth for this method |
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
my $param = shift; |
40
|
|
|
|
|
|
|
my $p = $param->{BizName}; |
41
|
|
|
|
|
|
|
my $l = $param->{address}; |
42
|
|
|
|
|
|
|
my $page = $param->{page}; |
43
|
|
|
|
|
|
|
my $request = $self->{request}."Biz.search?BizName=$p&address=$l&page=$page"; |
44
|
|
|
|
|
|
|
my $response = XMLin($self->_get($request)); |
45
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
46
|
|
|
|
|
|
|
return $response->{BizList}; |
47
|
|
|
|
|
|
|
} else { |
48
|
|
|
|
|
|
|
return 0; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub BizgetDetails { |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
my $param = shift; |
55
|
|
|
|
|
|
|
my $id = $param->{id}; |
56
|
|
|
|
|
|
|
my $request = $self->{request}."Biz.getDetails?ID=$id"; |
57
|
|
|
|
|
|
|
my $response = XMLin($self->_get($request)); |
58
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
59
|
|
|
|
|
|
|
return $response->{Biz}; |
60
|
|
|
|
|
|
|
} else { |
61
|
|
|
|
|
|
|
return 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub BizlistReviews { |
66
|
|
|
|
|
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
my $param = shift; |
68
|
|
|
|
|
|
|
my $id = $param->{id}; |
69
|
|
|
|
|
|
|
my $begin = $param->{begin} || 0; |
70
|
|
|
|
|
|
|
my $limit = $param->{limit} || 10; |
71
|
|
|
|
|
|
|
my $request = $self->{request}."Biz.listReviews?id=$id&begin=$begin&limit=$limit"; |
72
|
|
|
|
|
|
|
my $response = XMLin($self->_get($request)); |
73
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
74
|
|
|
|
|
|
|
return $response->{ReviewList}; |
75
|
|
|
|
|
|
|
} else { |
76
|
|
|
|
|
|
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub BizlistBuzzBizs { |
81
|
|
|
|
|
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
my $request = $self->{request}."Biz.listBuzzBizs"; |
83
|
|
|
|
|
|
|
my $response = XMLin($self->_get($request)); |
84
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
85
|
|
|
|
|
|
|
return $response->{BizList}; |
86
|
|
|
|
|
|
|
} else { |
87
|
|
|
|
|
|
|
return 0; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub ClasslistClasses { |
92
|
|
|
|
|
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
my $request = $self->{request}."Class.listClasses"; |
94
|
|
|
|
|
|
|
my $response = XMLin($self->_get($request)); |
95
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
96
|
|
|
|
|
|
|
return $response->{ClassList}; |
97
|
|
|
|
|
|
|
} else { |
98
|
|
|
|
|
|
|
return 0; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub ClasslistBizsInRange { |
103
|
|
|
|
|
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
my $param = shift; |
105
|
|
|
|
|
|
|
my $class = $param->{class} || 0; |
106
|
|
|
|
|
|
|
my $lon = $param->{lon} || '121.5438'; |
107
|
|
|
|
|
|
|
my $lat = $param->{lat} || '25.0417'; |
108
|
|
|
|
|
|
|
my $request = $self->{request}."Class.listBizsInRange?class=$class&lon=$lon&lat=$lat"; |
109
|
|
|
|
|
|
|
my $response = XMLin($self->_get($request)); |
110
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
111
|
|
|
|
|
|
|
return $response->{BizList}; |
112
|
|
|
|
|
|
|
} else { |
113
|
|
|
|
|
|
|
return 0; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub BizaddReview { |
118
|
|
|
|
|
|
|
my $self = shift; |
119
|
|
|
|
|
|
|
my $param = shift; |
120
|
|
|
|
|
|
|
my $comment = $param->{comment}; |
121
|
|
|
|
|
|
|
if ($self->auth && $self->auth->validate_sig()) { |
122
|
|
|
|
|
|
|
my $request = $self->{request}."Biz.addReview?comment=$comment"; |
123
|
|
|
|
|
|
|
return $self->auth->auth_ws_get_call($request); |
124
|
|
|
|
|
|
|
} else { |
125
|
|
|
|
|
|
|
return 0; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub UserlistBookmarks { |
130
|
|
|
|
|
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
if ($self->auth && $self->auth->validate_sig()) { |
132
|
|
|
|
|
|
|
my $request = $self->{request}."User.listBookmarks"; |
133
|
|
|
|
|
|
|
my $response = XMLin( $self->auth->auth_ws_get_call($request)); |
134
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
135
|
|
|
|
|
|
|
return $response->{BookmarkList}; |
136
|
|
|
|
|
|
|
} else { |
137
|
|
|
|
|
|
|
return 0; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} else { |
140
|
|
|
|
|
|
|
return 0; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub UserlistReviews { |
145
|
|
|
|
|
|
|
my $self = shift; |
146
|
|
|
|
|
|
|
my $param = shift; |
147
|
|
|
|
|
|
|
my $biz = $param->{biz}; |
148
|
|
|
|
|
|
|
my $request; |
149
|
|
|
|
|
|
|
if ($biz) { |
150
|
|
|
|
|
|
|
$request = $self->{request}."User.listReviews?biz=$biz"; |
151
|
|
|
|
|
|
|
} else { |
152
|
|
|
|
|
|
|
$request = $self->{request}."User.listReviews"; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
if ($self->auth->auth_ws_get_call($request)) { |
155
|
|
|
|
|
|
|
my $response = XMLin($self->auth->auth_ws_get_call($request)); |
156
|
|
|
|
|
|
|
if ($response->{status} eq 'ok') { |
157
|
|
|
|
|
|
|
return $response->{ReviewList}; |
158
|
|
|
|
|
|
|
} else { |
159
|
|
|
|
|
|
|
return 0; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} else { |
162
|
|
|
|
|
|
|
return 0; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub _get { |
168
|
|
|
|
|
|
|
my $self = shift; |
169
|
|
|
|
|
|
|
my $url = shift; |
170
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
171
|
|
|
|
|
|
|
$url .= "&appid=".$self->{appid}; |
172
|
|
|
|
|
|
|
my $req = HTTP::Request->new(POST => $url); |
173
|
|
|
|
|
|
|
my $res = $ua->request($req); |
174
|
|
|
|
|
|
|
if ($res->is_success) { |
175
|
|
|
|
|
|
|
return $res->content; |
176
|
|
|
|
|
|
|
} else { |
177
|
|
|
|
|
|
|
return $res->status_line; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
__END__ |