금융결제원 API 사용해보신분 계신가요? > 공지사항 | 그누보드5

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

  • profile_image
    아닌빽도
    • 0건
    • 128회
    • 17-07-24 14:23

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

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

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


index.php
[code]

<?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>";

[/code]


callback.php

[code]

<?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>';

[/code]


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




댓글0

등록된 댓글이 없습니다.

댓글
자동등록방지 숫자를 순서대로 입력하세요.
이름
비번
로고

You can relay on our amazing features list and also our customer services will be great experience.

our amazing features list and also our customer services is great.

(재)에버그린 어린이재단

경기도 성남시
분당구 정자동 123-456
2층, 3층, 4층

02-1234-5678
© All Rights Reserved by (재)에버그린 어린이재단