@@ -107,9 +107,9 @@ public function start()
107
107
{
108
108
while (1 )
109
109
{
110
- $ fp = fsockopen (" ssl://stream.twitter.com " , 443 , $ errno , $ errstr , 30 );
111
- if (!$ fp ){
112
- echo " ERROR: Twitter Stream Error: failed to open socket" ;
110
+ $ fp = fsockopen (' ssl://stream.twitter.com ' , 443 , $ errno , $ errstr , 30 );
111
+ if (!$ fp ){
112
+ throw new \ Exception ( ' Twitter stream failed to open socket ' ) ;
113
113
}else {
114
114
115
115
fwrite ($ fp , $ this ->_buildRequest ());
@@ -118,22 +118,21 @@ public function start()
118
118
119
119
while (!feof ($ fp ))
120
120
{
121
- $ read = array ($ fp );
122
- $ write = null ;
121
+ $ read = array ($ fp );
122
+ $ write = null ;
123
123
$ except = null ;
124
124
125
125
$ res = stream_select ($ read , $ write , $ except , 600 , 0 );
126
- if (( $ res == false ) || ( $ res == 0 ) ){
126
+ if ($ res === false || $ res === 0 ){
127
127
break ;
128
128
}
129
129
130
130
$ json = fgets ($ fp );
131
131
132
- if (strncmp ($ json , 'HTTP/1.1 ' , 8 ) == 0 ){
132
+ if (strncmp ($ json , 'HTTP/1.1 ' , 8 ) = == 0 ){
133
133
$ json = trim ($ json );
134
- if ($ json != 'HTTP/1.1 200 OK ' ){
135
- echo 'ERROR: ' . $ json . "\n" ;
136
- return false ;
134
+ if ($ json !== 'HTTP/1.1 200 OK ' ){
135
+ throw new \Exception ('ERROR: ' . $ json . "\n" ;
137
136
}
138
137
}
139
138
@@ -162,11 +161,9 @@ public function start()
162
161
}
163
162
}
164
163
}
165
-
166
164
fclose ($ fp );
167
165
sleep (10 );
168
166
}
169
-
170
167
return ;
171
168
}
172
169
};
0 commit comments