66 lines
2.7 KiB
PHP
66 lines
2.7 KiB
PHP
<?php
|
|
|
|
class DIGITAL_LOCKER
|
|
{
|
|
|
|
public static function getAccessToken($code)
|
|
{
|
|
log_message('ERROR','#### Helper Inside Get Access Token');
|
|
$CI =&get_instance();
|
|
$headers = array('Content-Type: multipart/form-data');
|
|
// $headers = array('Content-Type: application/json');
|
|
$ch = curl_init();
|
|
$fields = array('code' => $code,'grant_type' =>'authorization_code','client_secret' =>'bbda9efeb26bff460434','client_id' =>'FE9E5D06','redirect_uri' => 'https://apitest.pdgenie.com/');
|
|
curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_TOKEN_URI);
|
|
curl_setopt( $ch,CURLOPT_POST, true );
|
|
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
|
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
|
|
$result=curl_exec($ch);
|
|
$response = json_decode($result);
|
|
curl_close( $ch );
|
|
|
|
if(isset($response->error_description)){
|
|
return array('dataStatus'=>false,'msg'=>$response->error_description);
|
|
}else{
|
|
log_message('ERROR',"### DIGILOCKER TOKEN URI response :".json_encode($response).$response->access_token);
|
|
return self::getFileIssuedList($response->access_token);
|
|
}
|
|
}
|
|
|
|
public static function getFileIssuedList($access_token)
|
|
{
|
|
log_message('ERROR','#### My Access Token'.$access_token);
|
|
$CI =&get_instance();
|
|
$headers = array('Authorization: Bearer '.$access_token);
|
|
$ch = curl_init();
|
|
curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_FILESLIST_URI);
|
|
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
|
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
|
$result=curl_exec($ch);
|
|
// $response = json_decode($result);
|
|
$response = $result;
|
|
log_message('ERROR',"### DIGILOCKER FILELIST URI :".json_encode($response));
|
|
curl_close( $ch );
|
|
return array('dataStatus'=>true,'records'=>$response);
|
|
}
|
|
|
|
public static function getParticularFile($file_uri,$access_token)
|
|
{
|
|
log_message('ERROR','#### My Access Token'.$access_token);
|
|
$CI =&get_instance();
|
|
$headers = array('Authorization: Bearer '.$access_token);
|
|
$ch = curl_init();
|
|
curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_GETFILE_URI.$file_uri);
|
|
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
|
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
|
$result=curl_exec($ch);
|
|
$response = json_decode($result);
|
|
log_message('ERROR',"### DIGILOCKER FILELIST URI :".json_encode($response));
|
|
curl_close( $ch );
|
|
return $response;
|
|
// return array('dataStatus'=>true,'records'=>$response);
|
|
}
|
|
}
|
|
|
|
?>
|