Skip to content

Commit 198360c

Browse files
author
Inbal Tako
committed
Update readme
2 parents 2f98f7d + 9c2a934 commit 198360c

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ SecureNative::init("YOUR_API_KEY", $options);
5151
```
5252
### Option 2: Initialize via API Key
5353

54+
Initialize using default options.
55+
5456
```php
5557
require_once __DIR__ . '/vendor/autoload.php';
5658

@@ -153,7 +155,7 @@ use SecureNative\sdk\SecureNativeContext;
153155

154156

155157
$ver = SecureNative::verify(array(
156-
'event' => EventTypes::LOG_IN,
158+
'event' => EventTypes::VERIFY,
157159
'userId' => '27',
158160
'context' => SecureNativeContext::fromRequest(),
159161
'userTraits' => (object)[

src/EventManager.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct($apiKey, SecureNativeOptions $secureNativeOptions)
2525

2626
public function buildEvent(EventOptions $opts)
2727
{
28-
$cookie = $opts->context->clientToken;
28+
$cookie = isset($opts->context->clientToken) ? $opts->context->clientToken : "";
2929
$cookieDecoded = Utils::decrypt($cookie, $this->apiKey);
3030
$clientToken = json_decode($cookieDecoded);
3131

@@ -36,11 +36,11 @@ public function buildEvent(EventOptions $opts)
3636
$cid = $clientToken && $clientToken->cid ? $clientToken->cid : '';
3737
$vid = $clientToken && $clientToken->vid ? $clientToken->vid : '';
3838
$fp = $clientToken && $clientToken->fp ? $clientToken->fp : '';
39-
$ip = $opts->context->ip ? $opts->context->ip : '';
40-
$remoteIp = $opts->context->remoteIp ? $opts->context->remoteIp : '';
41-
$method = $opts->context->method ? $opts->context->method : '';
42-
$url = $opts->context->url ? $opts->context->url : '';
43-
$headers =$opts->context->headers ? $opts->context->headers : null;
39+
$ip = isset($opts->context->ip) ? $opts->context->ip : '';
40+
$remoteIp = isset($opts->context->remoteIp) ? $opts->context->remoteIp : '';
41+
$method = isset($opts->context->method) ? $opts->context->method : '';
42+
$url = isset($opts->context->url) ? $opts->context->url : '';
43+
$headers = isset($opts->context->headers) ? $opts->context->headers : null;
4444

4545
$reqCtx = new RequestContext($cid, $vid, $fp, $ip, $remoteIp, $method, $url, $headers);
4646

src/Utils.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static function headersFromRequest()
3939
foreach ($_SERVER as $key => $val) {
4040
if (substr($key, 0, 5) == 'HTTP_') {
4141
$name = strtolower(substr($key, 5));
42+
$name = str_replace("_", "-", $name);
4243
$headers[$name] = $val;
4344
}
4445
}

0 commit comments

Comments
 (0)