Skip to content

Commit 87dc35a

Browse files
committed
Merge branch 'fix-signature' into develop
2 parents f3ee068 + e21c4d6 commit 87dc35a

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

src/Client/Signature.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ public function __construct(array $params, $secret)
4343
//sort params
4444
ksort($this->signed);
4545

46+
$signed = [];
47+
foreach ($this->signed as $key => $value) {
48+
$signed[$key] = str_replace(array("&", "="), "_", $value);
49+
}
50+
4651
//create base string
47-
$base = '&'.urldecode(http_build_query($this->signed));
52+
$base = '&'.urldecode(http_build_query($signed));
4853

4954
//append the secret
50-
$base .= $secret;
55+
$base .= $secret;
5156

5257
//create hash
5358
$this->signed['sig'] = md5($base);

test/Client/SignatureTest.php

+38-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testSignature($sig, $params, $secret)
4444
public function signatures()
4545
{
4646
return array(
47-
//real signature
47+
//inbound
4848
array('d2e7b1dc968737c5998ad624e02f90b7', array(
4949
'message-timestamp' => '2013-11-21 15:27:30',
5050
'messageId' => '020000001B0FE827',
@@ -85,7 +85,43 @@ public function signatures()
8585
'to' => '14849970568',
8686
'type' => 'text',
8787
'sig' => '83c052a82906ec7c116e16f6d92f7eee'
88-
), 'my_secret_key_for_testing')
88+
), 'my_secret_key_for_testing'),
89+
90+
array('ff933bf31c79ab3fc6a38d100191c48f', array(
91+
'keyword' => 'TESTINGS',
92+
'message-timestamp' => '2017-04-04 23:05:22',
93+
'messageId' => '0C00000027217D5B',
94+
'msisdn' => '14843472194',
95+
'nonce' => 'c4ab6ed2-9bf5-48a0-af91-107e29bdd399',
96+
'sig' => 'ff933bf31c79ab3fc6a38d100191c48f',
97+
'text' => 'Testings',
98+
'timestamp' => '1491347122',
99+
'to' => '12192259404',
100+
'type' => 'text',
101+
), 'my_secret_key_for_testing'),
102+
103+
array('e06d9763e3fd0b9c31beb5fc2fcb011c', array(
104+
'keyword' => 'TEST',
105+
'message-timestamp' => '2017-04-04 22:57:47',
106+
'messageId' => '0B00000042AC53BD',
107+
'msisdn' => '14843472194',
108+
'nonce' => '929d6744-bd28-42c8-b6cf-31d5b4f43732',
109+
'sig' => 'e06d9763e3fd0b9c31beb5fc2fcb011c',
110+
'text' => 'Test with & and =',
111+
'timestamp' => '1491346667',
112+
'to' => '12192259404',
113+
'type' => 'text'
114+
), 'my_secret_key_for_testing'),
115+
116+
//outbound
117+
array('17f5e3b22f778ec73464c01d180e9d0f', array(
118+
'api_key' => 'not_a_key',
119+
'from' => '12192259404',
120+
'text' => '14843472194',
121+
'text' => 'Test&test=something',
122+
'timestamp' => '1490638615',
123+
'to' => '14843472194',
124+
), 'my_secret_key_for_testing'),
89125
);
90126
}
91127

0 commit comments

Comments
 (0)