금융결제원 API 사용해보신분 계신가요? > 자유게시판

자유게시판

금융결제원 API 사용해보신분 계신가요? 정보

금융결제원 API 사용해보신분 계신가요?

본문

https://developers.open-platform.or.kr/

딱히... 쓸곳이 없네요 ㅎㅎㅎ....

심심해서 만들다 귀찮아서 때려 치웁니다.~(개인이라 활용폭 제한이 있...)


index.php

<?php
$key = '';
$secret = '';
$base = 'https://testapi.open-platform.or.kr'; // 'https://openapi.open-platform.or.kr';
$redirect = 'https://z9n.net/bank/callback.php';

$ApiUrl = $base.'/oauth/2.0/authorize?response_type=code&client_id='.$key.'&redirect_uri='.urlencode($redirect).'&scope=login&client_info=';


echo "<a href=\"{$ApiUrl}\" target=\"_blank\">{$ApiUrl}</a>";


callback.php


<?php
$key = '';
$secret = '';
$base = 'https://testapi.open-platform.or.kr'; // 'https://openapi.open-platform.or.kr';
$redirect = '';


$code = $_REQUEST['code'];
$TUrl = $base.'/oauth/2.0/token';










//------------------- obb계열 ----------------------- //
$Param = array(
    'code'=>$code,
    'client_id'=>$key,
    'client_secret'=>$secret,
    'redirect_uri'=>$redirect,
    'grant_type'=>'client_credentials',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $TUrl);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($Param));
curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json'
));
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = (array)json_decode($response);
echo '<pre>';
echo 'obb토큰요청'.PHP_EOL;
print_r($response);
echo '</pre><hr>';



$TUrlSub = $base.'/bank/status';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $TUrlSub);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Accept: application/json',
    'Authorization: Bearer '.$response['access_token']
));
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = (array)json_decode($response);
echo '<pre>';
echo '참여은행정보'.PHP_EOL;
print_r($response);
echo '</pre><hr>';



























//------------------- 사용자계열 ----------------------- //
$Param = array(
    'code'=>$code,
    'client_id'=>$key,
    'client_secret'=>$secret,
    'redirect_uri'=>$redirect,
    'grant_type'=>'authorization_code',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $TUrl);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($Param));
curl_setopt ($ch, CURLOPT_POSTFIELDSIZE, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/x-www-form-urlencoded',
    'Accept: application/json'
));
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = (array)json_decode($response);
echo '<pre>';
echo '사용자토큰요청'.PHP_EOL;
print_r($response);
echo '</pre><hr>';



$TUrlSub = $base.'/user/me?user_seq_no='.$response['user_seq_no'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $TUrlSub);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Accept: application/json',
    'Authorization: Bearer '.$response['access_token']
));
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = (array)json_decode($response);
echo '<pre>';
echo '사용자정보'.PHP_EOL;
print_r($response);
echo '</pre><hr>';


혹시 필요하신분만 사용하세요 ㅎㅎ




추천
2
  • 복사

댓글 16개

메뉴얼이 워낙 잘되있지 못해?서 고생을 하긴 했습니다.
ppt를 포함하여 3개의 페이지를 열어야 하나가 나오더라구요.
개인이라 실서비스 모드로 전환이 안될가능 성이 큽니다 ㅎㅎ(심사라는 과정이 있더라구요...)
계좌 이체 까지 가능한 api라 그럴수도있지만....
© SIRSOFT
현재 페이지 제일 처음으로