@@ -32,7 +32,7 @@ |
||
32 | 32 | * |
33 | 33 | * @param string $keystorePath Path public key store file (PHP) |
34 | 34 | * |
35 | - * @return PhpFile public key store |
|
35 | + * @return Threema\MsgApi\PublicKeyStores\PhpFile public key store |
|
36 | 36 | */ |
37 | 37 | function CreatePublicKeyStore($keystorePath) |
38 | 38 | { |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * |
19 | 19 | * @return Connection $connector |
20 | 20 | */ |
21 | -function CreateConnection($keystorePath='../../keystore.php', $useTlsOptions=true) |
|
21 | +function CreateConnection($keystorePath = '../../keystore.php', $useTlsOptions = true) |
|
22 | 22 | { |
23 | 23 | $publicKeyStore = CreatePublicKeyStore($keystorePath); |
24 | 24 | $settings = CreateConnectionSettings($publicKeyStore, $useTlsOptions); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param string $threemaId The id whose public key should be fetched |
35 | 35 | * @param string $message The message to send (max 3500 characters) |
36 | 36 | * |
37 | - * @return string|Exception |
|
37 | + * @return string |
|
38 | 38 | */ |
39 | 39 | function SendMessage($connector, $threemaId, $message) |
40 | 40 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | //get params |
52 | 52 | if (ReturnGetPost('recieverid') && |
53 | - preg_match('/' . REGEXP_THREEMAID_ANY . '/', ReturnGetPost('recieverid')) |
|
53 | + preg_match('/'.REGEXP_THREEMAID_ANY.'/', ReturnGetPost('recieverid')) |
|
54 | 54 | ) { |
55 | 55 | $threemaId = htmlentities(ReturnGetPost('recieverid')); |
56 | 56 | $message = ReturnGetPost('message'); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | //Show direct output if the file is called directly |
78 | 78 | if (!$isIncluded) { |
79 | 79 | if ($errorMessage == null) { |
80 | - echo 'Message ID: ' . $messageId; |
|
80 | + echo 'Message ID: '.$messageId; |
|
81 | 81 | } else { |
82 | 82 | echo $errorMessage; |
83 | 83 | } |
@@ -12,10 +12,10 @@ |
||
12 | 12 | * @param string optional suffix (usually 'private:' or 'public:') (default: '') |
13 | 13 | * @return bool whether the key is valid (true) or not (false) |
14 | 14 | */ |
15 | -function KeyCheck($publicKey, $suffix='') |
|
15 | +function KeyCheck($publicKey, $suffix = '') |
|
16 | 16 | { |
17 | 17 | // RegExp: https://regex101.com/r/sU5tC8/1 |
18 | - return preg_match('/^(' . $suffix . ')?[[:alnum:]]{64}$/', $publicKey); |
|
18 | + return preg_match('/^('.$suffix.')?[[:alnum:]]{64}$/', $publicKey); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | function FetchPublicKey($connector, $threemaId) |
34 | 34 | { |
35 | 35 | $result = $connector->fetchPublicKey($threemaId); |
36 | - if($result->isSuccess()) { |
|
36 | + if ($result->isSuccess()) { |
|
37 | 37 | return $result->getPublicKey(); |
38 | 38 | } |
39 | 39 | else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | //get params |
45 | 45 | $threemaId = null; |
46 | 46 | if (ReturnGetPost('threemaid') && |
47 | - preg_match('/' . REGEXP_THREEMAID_ANY . '/', ReturnGetPost('threemaid')) |
|
47 | + preg_match('/'.REGEXP_THREEMAID_ANY.'/', ReturnGetPost('threemaid')) |
|
48 | 48 | ) { |
49 | 49 | $threemaId = htmlentities(ReturnGetPost('threemaid')); |
50 | 50 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $fileConnCredentErr .= ' Not all required constants are defined.'; |
60 | 60 | } else { |
61 | 61 | if (MSGAPI_GATEWAY_THREEMA_ID == '' || |
62 | - !preg_match('/' . REGEXP_THREEMAID_GATEWAY . '/', MSGAPI_GATEWAY_THREEMA_ID) |
|
62 | + !preg_match('/'.REGEXP_THREEMAID_GATEWAY.'/', MSGAPI_GATEWAY_THREEMA_ID) |
|
63 | 63 | ) { |
64 | 64 | $fileConnCredentErr .= ' \'MSGAPI_GATEWAY_THREEMA_ID\' is invalid.'; |
65 | 65 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | if (MSGAPI_DEFAULTRECEIVER <> '' && |
79 | - !preg_match('/' . REGEXP_THREEMAID_ANY . '/', MSGAPI_DEFAULTRECEIVER) |
|
79 | + !preg_match('/'.REGEXP_THREEMAID_ANY.'/', MSGAPI_DEFAULTRECEIVER) |
|
80 | 80 | ) { |
81 | 81 | $fileConnCredentErr .= ' \'MSGAPI_DEFAULTRECEIVER\' is invalid.'; |
82 | 82 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | <!-- files already exist - no need to show instructions --> |
135 | 135 | <?php else: ?> |
136 | 136 | <p> |
137 | - Before you can use this test you have to get credentials at <a href="https://gateway.threema.ch" title="Threema Gateway">gateway.threema.ch</a> and <a href="https://github.com/rugk/threema-msgapi-sdk-php/wiki/How-to-generate-a-new-key-pair-and-send-a-message">create a key pair</a>. After you did so, you have to open <code><?php echo FILENAME_CONNCRED . FILEEXT_EXAMPLE ?></code> and <code><?php echo FILENAME_PRIVKEY . FILEEXT_EXAMPLE ?></code> and add your credentials and private key. Save them without the <code><?php echo FILEEXT_EXAMPLE ?></code> file extension afterwards. |
|
137 | + Before you can use this test you have to get credentials at <a href="https://gateway.threema.ch" title="Threema Gateway">gateway.threema.ch</a> and <a href="https://github.com/rugk/threema-msgapi-sdk-php/wiki/How-to-generate-a-new-key-pair-and-send-a-message">create a key pair</a>. After you did so, you have to open <code><?php echo FILENAME_CONNCRED.FILEEXT_EXAMPLE ?></code> and <code><?php echo FILENAME_PRIVKEY.FILEEXT_EXAMPLE ?></code> and add your credentials and private key. Save them without the <code><?php echo FILEEXT_EXAMPLE ?></code> file extension afterwards. |
|
138 | 138 | By default these files are excluded from git pulls so you will not accidentally publish these sensitive files. |
139 | 139 | </p> |
140 | 140 | <?php endif ?> |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | </fieldset> |
222 | 222 | <fieldset id="field_method"> |
223 | 223 | <legend>Method</legend> |
224 | - <input id="SrvMethodGet" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') {echo 'checked="checked"';}?> value="get"> |
|
224 | + <input id="SrvMethodGet" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') {echo 'checked="checked"'; }?> value="get"> |
|
225 | 225 | <label for="SrvMethodGet">GET</label> |
226 | - <input id="SrvMethodPost" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') {echo 'checked="checked"';}?> value="post"> |
|
226 | + <input id="SrvMethodPost" name="servermethod" type="radio" <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') {echo 'checked="checked"'; }?> value="post"> |
|
227 | 227 | <label for="SrvMethodPost">POST</label> |
228 | 228 | <br /> |
229 | 229 | <input id="ButtonExternalScript" name="isExternal" type="checkbox"> |
@@ -39,10 +39,10 @@ |
||
39 | 39 | $result = $e2eHelper->sendTextMessage($receiverId, $message); |
40 | 40 | |
41 | 41 | //show result |
42 | - if(true === $result->isSuccess()) { |
|
43 | - echo 'Message ID: '.$result->getMessageId() . "\n"; |
|
42 | + if (true === $result->isSuccess()) { |
|
43 | + echo 'Message ID: '.$result->getMessageId()."\n"; |
|
44 | 44 | } else { |
45 | - echo 'Error: '.$result->getErrorMessage() . "\n"; |
|
45 | + echo 'Error: '.$result->getErrorMessage()."\n"; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | } |