@@ -142,7 +142,7 @@ public function call($module, $function, $args = array())
142
142
$ parameters = '' ;
143
143
if ( count ($ args ) > 0 ) {
144
144
foreach ( $ args as $ key => $ value ) {
145
- $ parameters .= '& ' . $ key . '= ' . $ value ;
145
+ $ parameters .= '& ' . $ key . '= ' . urlencode ( $ value) ;
146
146
}
147
147
}
148
148
@@ -167,30 +167,39 @@ public function call($module, $function, $args = array())
167
167
CURLOPT_RETURNTRANSFER => true ,
168
168
CURLOPT_ENCODING => "" ,
169
169
CURLOPT_MAXREDIRS => 10 ,
170
- CURLOPT_TIMEOUT => 30 ,
170
+ CURLOPT_TIMEOUT => 100020 ,
171
171
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1 ,
172
172
CURLOPT_CUSTOMREQUEST => "GET " ,
173
173
CURLOPT_POSTFIELDS => "" ,
174
174
CURLOPT_HTTPHEADER => $ headers ,
175
175
));
176
176
177
- $ response = curl_exec ($ curl );
177
+ $ curl_res = curl_exec ($ curl );
178
178
$ err = curl_error ($ curl );
179
+ $ err_no = curl_errno ($ curl );
180
+ $ header_size = curl_getinfo ($ curl , CURLINFO_HEADER_SIZE );
181
+ $ header = substr ($ curl_res , 0 , $ header_size );
182
+ $ body = substr ($ curl_res , $ header_size );
179
183
180
184
curl_close ($ curl );
181
185
182
186
183
- if ($ err ) {
187
+ $ response ['inputs ' ]['url ' ] = $ url ;
188
+ $ response ['data ' ]['header_size ' ] = $ header_size ;
189
+ $ response ['data ' ]['header ' ] = $ header ;
190
+ $ response ['data ' ]['response ' ] = json_decode ($ curl_res );
191
+ $ response ['data ' ]['body ' ] = $ body ;
192
+ $ response ['data ' ]['error ' ] = $ err ;
193
+ $ response ['data ' ]['err_no ' ] = $ err_no ;
194
+
195
+
196
+ if ($ err || $ err_no ) {
184
197
185
198
$ response ['status ' ] = 'failed ' ;
186
199
$ response ['errors ' ] = $ err ;
187
- $ response ['inputs ' ]['url ' ] = $ url ;
188
200
189
201
} else {
190
202
191
- $ res = json_decode ($ response );
192
-
193
- $ response = [];
194
203
if (isset ($ res ) && isset ($ res ->status ) && $ res ->status == 0 )
195
204
{
196
205
$ response ['status ' ] = 'failed ' ;
@@ -199,7 +208,6 @@ public function call($module, $function, $args = array())
199
208
} else
200
209
{
201
210
$ response ['status ' ] = 'success ' ;
202
- $ response ['data ' ] = $ res ;
203
211
$ response ['inputs ' ]['url ' ] = $ url ;
204
212
}
205
213
}
0 commit comments