File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ public function doCall(
83
83
$ parameters ['method ' ] = (string ) $ method ;
84
84
$ parameters ['format ' ] = 'json ' ;
85
85
86
+ // when we need authentication we need to add some extra parameters
87
+ if ($ authenticate ) {
88
+ $ parameters ['email ' ] = $ this ->getEmail ();
89
+ $ parameters ['nonce ' ] = md5 (microtime (true ) + rand (0 , time ()));
90
+ $ parameters ['secret ' ] = $ this ->getSecret ($ parameters ['nonce ' ]);
91
+ }
92
+
86
93
// HTTP method
87
94
if ($ httpMethod == 'POST ' ) {
88
95
$ options [CURLOPT_POST ] = true ;
@@ -172,6 +179,20 @@ public function getTimeOut()
172
179
return $ this ->timeOut ;
173
180
}
174
181
182
+ /**
183
+ * Calculate the secret
184
+ *
185
+ * @param string $nonce
186
+ * @return string
187
+ */
188
+ private function getSecret ($ nonce )
189
+ {
190
+ $ base = $ this ->getEmail ();
191
+ $ base .= $ this ->getApiKey ();
192
+
193
+ return sha1 (md5 ($ nonce ) . md5 ($ base ));
194
+ }
195
+
175
196
/**
176
197
* Get the useragent that will be used. Our version will be prepended to
177
198
* yours.
You can’t perform that action at this time.
0 commit comments