Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
18
Indexable
Never
$url = 'https://testwebservice.datachecker.nl/checkid';
$key = '4dcff8120a68809b25883ab6f9fb2071fd2a7233fac4498ea41c98f7145bfec7';
$id = '16530';
$docType = 'id';
$requestArray = [
        'checkType' => 'basic',
        'docType' => $docType,
        'images' => $images,
        'callbackUrl' => $callback,
        'livePhotos' => $selfie,
        'withFaceLink' => true,
    ];
    
    $request = json_encode($requestArray);
    $timestamp = time();
    $token = hash_hmac('sha256', $id . $timestamp . mb_strlen($request, '8bit'), $key);

    $headers = [
        'Content-Type' => 'application/json',
        'Authentication' => $id . ":" . $token,
        'Timestamp' => $timestamp,
        'Length' => mb_strlen($request, '8bit')
    ];

    $client = new \GuzzleHttp\Client();
    try {
        $response = $client->post($url, [
            \GuzzleHttp\RequestOptions::JSON => $requestArray,
            \GuzzleHttp\RequestOptions::HEADERS => $headers
        ]);

        $data = json_decode($response->getBody()->__toString());
        dd($data);