136 lines
5.8 KiB
PHP
136 lines
5.8 KiB
PHP
<?php
|
|
|
|
class DIGITAL_LOCKER
|
|
{
|
|
|
|
static $TOKEN_AS_GLOBAl = null;
|
|
static public $myVAR = null;
|
|
|
|
public static function getAccessToken($code,$applicant)
|
|
{
|
|
log_message('ERROR',"### 2 Msg : Inside Digi Helper getAccessToken Fns");
|
|
log_message('ERROR',"### 2 Params : i have code :".$code." & applicant :".$applicant);
|
|
$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/sparqtest/api/getDigiLockerDocs');
|
|
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 );
|
|
log_message('ERROR',"### 2 Response :".json_encode($response));
|
|
if(isset($response->error_description)){
|
|
log_message('ERROR',"### 2 Error :".$response->error_description);
|
|
return array('dataStatus'=>false,'msg'=>$response->error_description);
|
|
}else{
|
|
log_message('ERROR',"### 3 Token :".$response->access_token);
|
|
$CI->db->SELECT("PDAPPLICANTSDETAILS.fk_pd_id,PDAPPLICANTSDETAILS.pd_co_applicant_id,PDAPPLICANTSDETAILS.applicant_name,
|
|
PDTRIGGER.lender_applicant_id, PDTRIGGER.pd_sno");
|
|
$CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS");
|
|
$CI->db->JOIN(PDTRIGGER .' as PDTRIGGER','PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id','LEFT');
|
|
$CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant);
|
|
$CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1);
|
|
$dtls = $CI->db->GET()->result_array();
|
|
// 9 840-2 714
|
|
$CI->db->where('pd_co_applicant_id',$applicant);
|
|
$CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $result));
|
|
// print_r($CI->db->last_query());die();
|
|
log_message('ERROR',"### 3 SQL Reponse :".json_encode($dtls));
|
|
return self::getFileIssuedList($response->access_token,$dtls);
|
|
}
|
|
}
|
|
|
|
public static function getFileIssuedList($access_token,$dtls)
|
|
{
|
|
log_message('ERROR',"### 4 Msg : Inside Helper getFileIssuedList");
|
|
log_message('ERROR',"### 4 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);
|
|
log_message('ERROR',"### 4 Reponse :".json_encode($result));
|
|
curl_close( $ch );
|
|
return array('dataStatus'=>true,'records'=>$result,'token'=>$access_token,'dtls'=>$dtls);
|
|
}
|
|
|
|
// public static function downloadFiles($uri,$access_token)
|
|
// {
|
|
// log_message('ERROR',"### 6 : Inside Helper DIGILOCKERGETFILEURI Token :".$access_token." & URI :".$uri);
|
|
// log_message('ERROR',"### 6.1 : Dummy API ");
|
|
// $image_url = "http://p.twimg.com/AW2-vIUCAAE_1FN.png";
|
|
|
|
// $ch = curl_init();
|
|
// curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
// curl_setopt ($ch, CURLOPT_URL, $image_url);
|
|
// curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
|
// curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
|
// curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
|
|
// curl_setopt($ch, CURLOPT_HEADER, true);
|
|
// curl_setopt($ch, CURLOPT_NOBODY, true);
|
|
|
|
// $content = curl_exec ($ch);
|
|
// log_message('ERROR',"### 6th : DIGILOCKERGETFILEURI Reponse :".json_encode($content));
|
|
// $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
|
|
// echo $contentType;
|
|
// echo "<br/>";
|
|
// curl_close ($ch);
|
|
// echo "<pre>";
|
|
// print_r($content);
|
|
// }
|
|
public static function downloadFiles($uri,$access_token)
|
|
{
|
|
log_message('ERROR',"### 7 MSG : Inside Helper DIGILOCKERGETFILEURI");
|
|
log_message('ERROR',"### 7 Token :".$access_token." & URI :".$uri);
|
|
$CI =&get_instance();
|
|
$headers = array('Authorization: Bearer '.$access_token);
|
|
$ch = curl_init();
|
|
curl_setopt( $ch,CURLOPT_URL, DIGILOCKER_GETFILE_URI.$uri);
|
|
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
|
|
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
|
|
$result=curl_exec($ch);
|
|
log_message('ERROR',"### 7 Reponse :".json_encode($result));
|
|
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
|
|
log_message('ERROR',"### 7 ContentType :".$contentType);
|
|
curl_close ($ch);
|
|
return $result;
|
|
}
|
|
|
|
|
|
public static function userCh_check1(){
|
|
global $myVAR;
|
|
self::userCh_check2();
|
|
return $var;
|
|
}
|
|
public static function userCh_check2(){
|
|
global $myVAR;
|
|
$myVAR = 7123;
|
|
}
|
|
public static function userCh_check3($code,$applicant){
|
|
$CI =&get_instance();
|
|
$CI->db->SELECT("PDAPPLICANTSDETAILS.fk_pd_id,PDAPPLICANTSDETAILS.pd_co_applicant_id,PDAPPLICANTSDETAILS.applicant_name,
|
|
PDTRIGGER.lender_applicant_id, PDTRIGGER.pd_sno");
|
|
$CI->db->FROM(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS");
|
|
$CI->db->JOIN(PDTRIGGER .' as PDTRIGGER','PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id','LEFT');
|
|
$CI->db->WHERE("PDAPPLICANTSDETAILS.pd_co_applicant_id",$applicant);
|
|
$CI->db->WHERE("PDAPPLICANTSDETAILS.isactive",1);
|
|
$dtls = $CI->db->GET()->result_array();
|
|
$pd_id = (count($dtls)>0) ? $dtls[0]['fk_pd_id'] : null;
|
|
$response = "bb";
|
|
$CI->db->where('pd_co_applicant_id',$applicant);
|
|
$CI->db->update(PDAPPLICANTSDETAILS, array('digi_locker_token' => $response));
|
|
|
|
}
|
|
public static function callTheFiles($src_local_file){
|
|
|
|
}
|
|
}
|
|
|
|
?>
|