data->accessToken; }else{ $token = null; } // $response_decoded = json_decode($result); // $response = $response_decoded; curl_close( $ch ); log_message('ERROR', "Smc Finance Auth Url token : " . $token); } catch (Exception $e) { $token = null; // $response->error = array($e->getMessage()); log_message('ERROR', "Smc Finance Auth Url ERR : " . $e->getMessage()); } return $token; } // 2. Refresh Token // API URL: http://ums.devopsmcfinance.com/umsnode/ums/api/v1/auth/access-token // TYPE : POST // BODY : { "refreshToken": {Refresh Token} } public static function SmcFinanceRefreshToken($token) { $CI =& get_instance(); // $headersData = getallheaders(); log_message('ERROR','#### Smc Finance Refresh Token in Helper FNS '); $headers = array('Content-Type: application/json'); try{ $ch = curl_init(); $body = '{ "refreshToken":$token'.$token.' }'; curl_setopt($ch, CURLOPT_URL, SMC_FINANCE_REFRESH_TOKEN); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS,$body); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true ); $result = curl_exec($ch ); $response_decoded = json_decode($result); $response = $response_decoded; curl_close( $ch ); log_message('ERROR','#### Smc Finance Refresh Token reponse '.$response); } catch (Exception $e) { $response->error = array($e->getMessage()); log_message('ERROR','#### Smc Finance Refresh Token reponse Err '. $e->getMessage()); } return $response; } // 3. API URL // API URL: http://devopsmcfinance.com/salesapi/salesapplication/v1/sales-lead/${salesid}/update-pd // TYPE : PUT // BODY : { "pdId": "MWISE-LFMP-357", "pdStatus": 1 } public static function SmcFinanceApiUrl($applicant_id,$sales_pd_id,$sales_pd_sno,$sales_pd_status,$token) { log_message('ERROR',"SMC Finance Api Fns ".$token); // 'Authorization:Zoho-oauthtoken '.$newaccesstoken, $headers = array('Content-Type: application/json','Authorization: Bearer '.$token); try{ $ch = curl_init(); $body = '{"pdId":"'.$sales_pd_sno.'","pdStatus":'.$sales_pd_status.',"salesLeadId":'.$applicant_id.'}'; // $object->pdId = $sales_pd_sno; // $object->pdStatus = $sales_pd_status; // $object->salesLeadId = $applicant_id; log_message('ERROR',"SMC Finance Api body ".$body); //$data1 = array("pdId" => $sales_pd_sno,"pdStatus"=>$sales_pd_status,"salesLeadId"=>$sales_pd_id); // $put_url = SMC_FINANCE_API_URL.$sales_pd_id.'/update-pd'; curl_setopt($ch, CURLOPT_URL, SMC_FINANCE_UPDATE_URL); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS,$body); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true ); $result = curl_exec($ch ); $response_decoded = json_decode($result); log_message('ERROR', "SMC Finance Api Fns Response : " . $result); curl_close( $ch ); } catch (Exception $e) { // $response->error = array($e->getMessage()); $result = array($e->getMessage()); log_message('ERROR', "SMC Finance Api Fns ERR : " . $e->getMessage()); } return $result; } }