@@ -71,73 +71,6 @@ public function qualifyForSolicitation($order)
71
71
return true ;
72
72
}
73
73
74
- private function initCurl ($ url )
75
- {
76
- $ this ->success = $ this ->json = null ;
77
- $ this ->ch = curl_init ($ url );
78
- curl_setopt ($ this ->ch , CURLOPT_USERPWD , $ this ->_user . ': ' . $ this ->_password );
79
- curl_setopt ($ this ->ch , CURLOPT_USERAGENT , $ this ->_user_agent );
80
- curl_setopt ($ this ->ch , CURLOPT_RETURNTRANSFER , true );
81
- curl_setopt ($ this ->ch , CURLOPT_FAILONERROR , false );
82
- // Some versions of openssl seem to need this
83
- // http://www.supermind.org/blog/763/solved-curl-56-received-problem-2-in-the-chunky-parser
84
- curl_setopt ($ this ->ch , CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_0 );
85
- // From http://it.toolbox.com/wiki/index.php/Use_curl_from_PHP_-_processing_response_headers
86
- curl_setopt ($ this ->ch , CURLOPT_HEADERFUNCTION , array (&$ this , 'storeHeaders ' ));
87
- $ this ->headers = '' ;
88
- }
89
-
90
- private function verbThePayload ($ verb , $ payload )
91
- {
92
- $ data_string = json_encode (Helper::removeNulls ($ payload ));
93
- curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , $ verb );
94
- curl_setopt ($ this ->ch , CURLOPT_POSTFIELDS , $ data_string );
95
- curl_setopt (
96
- $ this ->ch ,
97
- CURLOPT_HTTPHEADER ,
98
- array (
99
- 'Accept: application/json ' ,
100
- 'Content-Type: application/json ' ,
101
- 'Content-Length: ' . strlen ($ data_string )
102
- )
103
- );
104
- $ this ->sendRequest ();
105
- }
106
-
107
- private function sendRequest ()
108
- {
109
- $ this ->succeess = false ;
110
- if ($ this ->_debug ) {
111
- curl_setopt ($ this ->ch , CURLOPT_SSL_VERIFYPEER , false );
112
- }
113
- $ this ->curl_result = curl_exec ($ this ->ch );
114
- $ this ->status = curl_getinfo ($ this ->ch , CURLINFO_HTTP_CODE );
115
- }
116
-
117
- private function dealWithResponse ()
118
- {
119
- if (200 <= $ this ->status && $ this ->status <= 299 ) {
120
- $ this ->success = true ;
121
- $ this ->log ("Start " . $ this ->status . ": Ok! " );
122
- } else {
123
- $ this ->success = false ;
124
- $ this ->json = json_decode ($ this ->curl_result , true );
125
- $ this ->log ("Start " . $ this ->status . ": " . $ this ->curl_result );
126
- }
127
- }
128
-
129
- private function log ($ msg )
130
- {
131
- if (!$ this ->_debug ) {
132
- return ;
133
- }
134
- if (!$ this ->_logfile ) {
135
- error_log ($ msg );
136
- } else {
137
- error_log ($ msg . "\n" , 3 , $ this ->_logfile );
138
- }
139
- }
140
-
141
74
public function getIdentificationForm ($ uri , $ options = array ())
142
75
{
143
76
$ options ["product " ] = array_key_exists ('product ' , $ options ) ? $ options ["product " ] : "i1 " ;
@@ -271,8 +204,6 @@ public function getJson()
271
204
return $ this ->json ;
272
205
}
273
206
274
- // Private methods below
275
-
276
207
public function getStatus ()
277
208
{
278
209
return $ this ->status ;
@@ -307,6 +238,75 @@ public function dump()
307
238
var_dump ($ this ->success );
308
239
}
309
240
241
+ // Private methods below
242
+
243
+ private function initCurl ($ url )
244
+ {
245
+ $ this ->success = $ this ->json = null ;
246
+ $ this ->ch = curl_init ($ url );
247
+ curl_setopt ($ this ->ch , CURLOPT_USERPWD , $ this ->_user . ': ' . $ this ->_password );
248
+ curl_setopt ($ this ->ch , CURLOPT_USERAGENT , $ this ->_user_agent );
249
+ curl_setopt ($ this ->ch , CURLOPT_RETURNTRANSFER , true );
250
+ curl_setopt ($ this ->ch , CURLOPT_FAILONERROR , false );
251
+ // Some versions of openssl seem to need this
252
+ // http://www.supermind.org/blog/763/solved-curl-56-received-problem-2-in-the-chunky-parser
253
+ curl_setopt ($ this ->ch , CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_0 );
254
+ // From http://it.toolbox.com/wiki/index.php/Use_curl_from_PHP_-_processing_response_headers
255
+ curl_setopt ($ this ->ch , CURLOPT_HEADERFUNCTION , array (&$ this , 'storeHeaders ' ));
256
+ $ this ->headers = '' ;
257
+ }
258
+
259
+ private function verbThePayload ($ verb , $ payload )
260
+ {
261
+ $ data_string = json_encode (Helper::removeNulls ($ payload ));
262
+ curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , $ verb );
263
+ curl_setopt ($ this ->ch , CURLOPT_POSTFIELDS , $ data_string );
264
+ curl_setopt (
265
+ $ this ->ch ,
266
+ CURLOPT_HTTPHEADER ,
267
+ array (
268
+ 'Accept: application/json ' ,
269
+ 'Content-Type: application/json ' ,
270
+ 'Content-Length: ' . strlen ($ data_string )
271
+ )
272
+ );
273
+ $ this ->sendRequest ();
274
+ }
275
+
276
+ private function sendRequest ()
277
+ {
278
+ $ this ->succeess = false ;
279
+ if ($ this ->_debug ) {
280
+ curl_setopt ($ this ->ch , CURLOPT_SSL_VERIFYPEER , false );
281
+ }
282
+ $ this ->curl_result = curl_exec ($ this ->ch );
283
+ $ this ->status = curl_getinfo ($ this ->ch , CURLINFO_HTTP_CODE );
284
+ }
285
+
286
+ private function dealWithResponse ()
287
+ {
288
+ if (200 <= $ this ->status && $ this ->status <= 299 ) {
289
+ $ this ->success = true ;
290
+ $ this ->log ("Start " . $ this ->status . ": Ok! " );
291
+ } else {
292
+ $ this ->success = false ;
293
+ $ this ->json = json_decode ($ this ->curl_result , true );
294
+ $ this ->log ("Start " . $ this ->status . ": " . $ this ->curl_result );
295
+ }
296
+ }
297
+
298
+ private function log ($ msg )
299
+ {
300
+ if (!$ this ->_debug ) {
301
+ return ;
302
+ }
303
+ if (!$ this ->_logfile ) {
304
+ error_log ($ msg );
305
+ } else {
306
+ error_log ($ msg . "\n" , 3 , $ this ->_logfile );
307
+ }
308
+ }
309
+
310
310
private function storeHeaders ($ ch , $ header )
311
311
{
312
312
$ this ->headers .= $ header ;
0 commit comments