NOTICE

2015/10/15 - [Programming/PHP] - 인스타그램 액세스 토큰(Access Token) 발급 방법...1

지난 번에 이어 두 번째다.
우선 Authentication 페이지로 가자.


다른 거 볼 필요도 없이 바로 Step One을 보면 된다.

Step One: Direct your user to our authorization URL
https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code

CLIENT-ID와 REDIRECT-URI는 상단 메뉴에 있는 Manage Clients를 클릭하면 볼 수 있다.

https://api.instagram.com/oauth/authorize/?client_id=adfad어쩌고저쩌고&redirect_uri=http://nyaongii.dothome.co.kr&response_type=code
CLIENT ID와 REDIRECT URI를 자기 걸로 바꾸고 브라우저 주소창에 넣어 보자.

Authorize라는 버튼이 보인다. 클릭!

그러면 저기에 적힌 자신의 홈페이지(나 같은 경우는 http://nyaongii.dothome.co.kr)로 이동이 되고 끝난다.
아 이거 뭐야! 사기꾼이네! 그러지 말고 주소창을 보자.

도메인 끝에 code라는 변수에 무언가 붙어 있다.
제일 위 이미지에 보면 Step Two 부분을 참고하자.

Step Two: Receive the redirect from Instagram
Once a user authorizes your application, we issue a redirect to your redirect_uri with a code parameter to use in step three.
http://your-redirect-uri?code=CODE

curl로 받으라고 한다. 저렇게 리눅스에서 해도 되지만 php로도 받으면 된다.


위 코드 그대로 index.php 파일 어딘가에 넣어 놓고 새로 고침을 하자!

stdClass Object ( [access_token] => 자체 생략! [user] => stdClass Object ( [username] => lazy_zzins [bio] => [website] => [profile_picture] => https://scontent.cdninstagram.com/t51.2885-19/11906194_1694798740741926_159704466_a.jpg [full_name] => zzins [id] => 2208240383 ) )

이런 식으로 나온다면 성공한 것이다.