I need to implement GBG id scan api to recognize uploaded identity documents verification.
I have tried as following. Platform is php codeigniter.
$img_path = base_url()."images/NID-1.jpg";
$img_content = file_get_contents($img_path);
$encode_img = base64_encode($img_content);
$img_path2 = base_url()."images/NID-2.jpg";
$img_content2 = file_get_contents($img_path2);
$encode_img2 = base64_encode($img_content2);
$ids_user_name = "XXXXXXXXXX";
$ids_passwd = "XXXXXXXXXXX";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://poc.idscan.cloud/idscanenterprisesvc/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'username='.$ids_user_name.'&password='.$ids_passwd.'&grant_type=password&area=scanning',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
$decode_response = json_decode($response);
$access_token = $decode_response->access_token;
$token_type = $decode_response->token_type;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://poc.idscan.cloud/idscanenterprisesvc/journey/upload',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>"{'InputImages': [{'Name':'WhiteImage','ImageFormat':'jpg','Data':'".$encode_img."'}],'IsDocumentExtracted':'false','Source':2}",
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$access_token,
'Content-Type: application/json'
),
));
$response1 = curl_exec($curl);
curl_close($curl);
$decode_response1 = json_decode($response1);
echo '<pre>';
print_r($decode_response1);
exit;
Response:
stdClass Object
(
[PersonEntryId] => 00000000-0000-0000-0000-000000000000
[EntryDateTime] => 0001-01-01T00:00:00
[CurrentResult] => ProcessingError
[IsFinished] =>
[RequestId] => 00000000-0000-0000-0000-000000000000
[HasError] =>
[EntryData] => stdClass Object(
)
)
pls Help me to solve this ProcessingError
i have referred this document https://docs.idscan.com/docs/ieos-web-api-8-7/actions/upload/
I need to upload identity document to IDscan backend to be processed along with an optional face match input data to match two faces.
Thanks in advance..
Related
I hope someone could help me to debug this PHP script. My problem is in line 40 which corresponds to customermobile
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://app.snipcart.com/api/orders/76328829-55d0-4037-884b-a7413b0fa0d2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Basic OlNfTW1ReVl6TmxNRGd0T0dNeU5TMDBPREZoTFRsalpXTXRNREV5Tm1ZMFlqVTFNVGcyTmpNM09UWXpPRFkyTkRrd01UazJNekEz'
),
));
$moredata = curl_exec($curl);
curl_close($curl);
echo $moredata;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://g.payx.ph/payment_request',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array(
'x-public-key' => 'pk_9219da5bc038b18ac8146e04f4984320',
'amount' => '100',
'customername' => 'Jane Doe',
'customermobile' => ($moredata->billingAddress->phone), // <--- this is the problem
'customeremail' => 'janedoe#fakeemail.com',
'description' => 'Payment for products',
),
));
$response = json_decode(curl_exec($curl));
$err = curl_error($curl);
curl_close($curl);
header('Location: '.$response->data->checkouturl);
?>
The field accepts up to 11 digits. I can't even pass the data from other fields like postal code.
So I have the code below, and it does the following:
request a key via a curl command
the key is then send back to another URL -
this command then returns a URL which I am trying to redirect too.
When it attempts to redirect, I get the following error : Warning: Header may not contain more than a single header, new line detected in C:\xampp\htdocs\blahblah\testapi.php on line 50
var_dump returns: string(39372) "https://pay.testdomain.com/eft?payment_key=0b1f024ccac63c7ce19ffad8b53a8d32"
<?php
ob_start();
#Get key
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://pay.testdomain.com/api/login-admin',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('email' => 'user#user.com','password' => 'mypassword'),
CURLOPT_HTTPHEADER => array(
'Accept: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response,true);
$key = $data['data']['token'];
#Get redirect URL
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://pay.testdomain.com/api/payment-redir',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('amount' => '100.5555','merchant_ref' => '2222','payment_method' => 'eft'),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . $key
),
));
$response = curl_exec($curl);
curl_close($curl);
header("Location: " . $response );
exit;
ob_end_flush();
Here is my code. Basically this snippet is called when the status of my food order gets changed and notification is sent to a user.
$dataNew = json_encode( array(
"title" => "Hellof",
"text" => "Rich Notification testing (body",
"sound" => "default"
));
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://fcm.googleapis.com/fcm/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('to' => $token,'data' => $orderDetails,'notification'=>$dataNew,'priority'=>"high"),
CURLOPT_HTTPHEADER => array(
'Accept: application/json'
),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ***********'
),
));
$response = curl_exec($curl);
curl_close($curl);
//echo $response;
}
I was able to find the access token from Azure
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://login.microsoftonline.com/12baf------------/oauth2/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'grant_type=client_credentials&client_id=XXXXX-57b4-XXXXb-XXXX-13ca1f5eec6e&client_secret=XXXXX&resource=https%3A%2F%2Fmanagement.azure.com%2F',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded',
'Cookie: fpc=AlXXXXXXXXpKm43KbQ52MOkk8jRRAQAAAI8Us9cOAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=prod'
),
));
$json = curl_exec($curl);
$data=json_decode($json,true);
curl_close($curl);
$token=$data['access_token'];
But when I am trying to pass the variable in CURLOPT_HTTPHEADER it's showing an invalid token.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://management.azure.com/subscriptions/XXXXXXX-1faf-4756-a709-1af49be58e56/resourcegroups?api-version=2020-06-01',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '$token'
),
));
$response = curl_exec($curl);
echo $response
?>
How can I pass the token in the above array or there is an easy way to do it? Can anyone please help here.
I able to resolve it as below
$authorization = "Authorization: Bearer ".$token;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://management.azure.com/subscriptions/xxxxxxx-4756-a709-1af49be58e56/resourcegroups?api-version=2020-06-01',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json' , $authorization)
),
);
$response = curl_exec($curl);
echo $response
?>
I am a beginner with curl. I want to make a request where I post different data.
I have a code
$curl = curl_init();
$fields = (object) array(
'contactFilter' => (object) array(
'clicked_message.messageid' => '5',
'messages_sent.messageid' => '5'
),
'exportAttributes' => 'email',
);
$fields = json_encode($fields);
$fields_string = http_build_query($fields);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sendinblue.com/v3/contacts/export",
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Content-Type: application/json',
'api-key: my-key-12345',
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $fields_string
));
$response = curl_exec($curl);
Documentation says that I need;
contactFilter object (X= campaign id): {"clicked_message.messageid": X,"messages_sent.messageid": X}
and
exportAttributes` array of strings For example, `['fname', 'lname, 'email'].
how should my request should look like?
You need to use CURLOPT_POSTFIELDS to post the fields, for example
$fields = array(
'username' => "annonymous",
'api_key' => "1234"
);
$fields_string = http_build_query($fields);
Now use variable fields_string to send array data
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
Your curl request will be look like
curl_setopt_array($curl,
array(
CURLOPT_URL => "https://api.sendinblue.com/v3/contacts/export",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $fields_string
)
);
Updated Code-
$curl = curl_init();
$fields = (object) array(
'contactFilter' => (object) array(
'clicked_message.messageid' => '5',
'messages_sent.messageid' => '5'
),
'exportAttributes' => 'email',
);
$fields = json_encode($fields);
//$fields_string = http_build_query($fields);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.sendinblue.com/v3/contacts/export",
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Content-Type: application/json',
'api-key: my-key-12345',
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $fields
));
$response = curl_exec($curl);
echo $response;
print_r($response);